Problem calling api due to botpress studio proxy

Hi everybody,

I am trying to do a remote call to an api in my botpress studio bot.

The api call works fine in postman. When calling the api directly it works fine (for testing puposes I didnt add the authorization and get a 401 unauthorized as expected.

curl  GET 'https://api.nuclino.com/v0/'

But it throws a 404 in when called in the “execute code” part of my botpress studio bot. Apparently a redirect is added automatically using the botress proxy.

The code looks like this:

const response = await axios.get('https://api.nuclino.com/v0/')

The logs state the following (if I call the url from the logs directly, I also get the 404 instead of the 401):

21:36:46errorError executing action "inline-ins-aedb7cfdff.js" in flow:Main:node:Standard
HTTP (get) URL https://botpress.studio/api/proxy/https%3A%2F%2Fapi.nuclino.com%2Fv0%2F
Received "Not found"
Request failed with status code 404

Any idea what I could try out to fix this?
Thanks for your help :slight_smile:

Hi @felix-gillen ,

I have just tried it, and it works for me. Did you add Authorization to the headers?

Hi,

thanks for the quick reply. My initial solutions involved parameters and authorization in headers, but I removed all parameters, authorization, and additional code to simplify the problem. My initial thought was the problem might be related to headers and the proxy.

This is how the whole simplified setup looks like. I get a 404 instead of the 401 I would expect.

Doing the same request in postman without authorization returns a 401 as expected:

When executing the redirect with the botpress proxy I can see in the error-logs from the first screenshot in postman, I get the following error:

Missing required request header. Must specify one of: origin,x-requested-with

When adding those headers to postman, I get the 404 as stated in the error logs instead of the 401 I would expect.

(sorry, I wasn’t allowed to add more screenshots as I am still a new user here :slight_smile: )

Which setup did work for you?

Okay, I tried the workspaces API and I got your error. I have opened a ticket to the team.

Sorry for any inconvenience.

No worries, thanks a lot. Could you eventually post a short update when the ticket has been solved or should I try again in a few days/weeks?

Okay, the team replied, it happens in the studio only, but if you published your bot and tried it again, it works in the chat windows. I know this is not a solution for development; the good news is it will work for your users and demos :wink:

Meanwhile, the team will look into it relaxingly because it doesn’t happen with most other integrations. But it is on their list now - since there is a ticket :smiling_imp:.

1 Like

I have tried it and it works from the channels.

1 Like