Why am I getting an HTTP interface error despite changing the customResponse setting from true to false?

This topic was automatically generated from Slack. You can find the original thread here.

Hi guys,

Pls I am getting this error on my source which is suppose to trigger every day… Not sure what it refers to, I tweaked the customResponse from true to false but no change

HTTP interface can not respond to this request, check httpInterface.customResponse setting

Hi Bashir,

Can you share the props source code? Are you using a $.service.http interface in the source?

**import** http **from** "../../http.app.mjs";
**import** axios **from** "axios";

// Core HTTP component
// Returns a 200 OK response, emits the HTTP payload as an event
export **default** {
key: "http-new-requests-payload-only",
name: "New Requests (Payload Only)",
// eslint-disable-next-line
description: "Get a URL and emit the HTTP body as an event on every request",
version: "0.1.1",
type: "source",
props: {
// eslint-disable-next-line
httpInterface: {
type: "$.interface.http",
customResponse: **false**,
},
http,
timer: {
type: "$.interface.timer",
**default**: {
cron: "0 0 ** ** **", _// Run job once a day_
},
},
invoice_ninja_auth_api_token: {
type: "string",
optional: **false**,
label: "Invoice Ninja Auth Api Token"
},
invoice_ninja_auth_domain: {
type: "string",
optional: **false**,
label: "Invoice Ninja Auth Domain"
}
},
**async** run(event) {
**const** { body } = event;
/** this.httpInterface.respond({
status: 200,
body,
});

_`**/`_

`**this**.httpInterface.respond({`
  `status: 200,`
  `body: "Successful processing",`
  `headers: {`
    `"content-type": "application/json",`
  `},`
`});`

//Basic sleep function
async **function** __sleep(milliseconds) {
**const** date = Date.now();
**let** currentDate = **null**;
**do** {
currentDate = Date.now();
} **while** (currentDate - date < milliseconds);
}

**function** delay(ms) {
return **new** Promise(resolve => {
setTimeout(resolve, ms);
});
}
**const** results = [];
**let** page = 1;
**let** total = 0;

**do** {
**try**{

`**var** response = **await** axios({`
  _`//  url: `${this.invoice_ninja.$auth.domain}/api/v1/products/${hashed_id}`,`_
 
    `url: `${**this**.invoice_ninja_auth_domain}/api/v1/invoices/?page=${page}`,`
    `headers: {`
      `"X-api-Token": `${**this**.invoice_ninja_auth_api_token}`,`
    `},`
    `data: {`
      `status_id:"3"`
    `}`
  `})`

//console.log(response.data.data)
// console.log( ${this.invoice_ninja_auth_domain}/api/v1/invoices/?page=${page}&created_at=2023-1-01)
results.push(...response.data.data);
console.log(results.length)
total = 10_// response.data.meta.pagination.total;_
page++;
**await** delay(200)

}
**catch**(error){
console.log("Error")
console.log(error)
}

} **while** (results.length < total);

//return results;

**let** count = 1
// Emit the HTTP payload
results.map(product=>{

  `**if** (!product.custom_value3 && product.amount!==0 && !product.is_deleted && (!product.number.toLowerCase().includes("delete"))){`

**this*.$emit({body: product}, {
summary: Emitting row ${count} + product.number,
})
count++
}

`});`

},
};

I think the issue might be that there are two ways to trigger the source, does that error occur when the source is triggered by the timer specifically?

Yes… Only way to trigger is via the timer

Ok, thanks for clearing that up. So you won’t need the $.interface.http. That’s adding another trigger to the source.

That interface generates a URL to trigger the workflow by webhook. So if the source is triggered by the timer, I believe what that error message means is that the source isn’t sure how to respond because there is no HTTP request.

I suggest removing that interface if you’re not using it

Thanks… I use it to trigger the source so I can test it… Any idea how I can manage that?

You can click Run Now in the source when it’s open in the Pipedream dashboard.

Here’s a link to the Sources area in the Pipedream dashboard.

This works with timer based sources too.