Unable to send POST request through Request API

I am trying to post a request to my own middleware at app installation.
I am getting 405 error code in return.
This has been verified that the same API is working fine with same data through postman.

image

Hi, @yusrakhatri!

There’s some points on you code to check:
When onAppInstall succeeds, renderData() should be called without any arguments!
When it fails, you are setting 403 manually, so perhaps is another error ocurring?

That been said, for using $request, your end point must be HTTPS and it must be declared in manifest.json.
Check those points, please.

5 Likes

Verified this. The endpoint is secured.
The endpoint allows both get and post, when I change post to get in the code, this works fine.

This same code was working absolutely fine until last week.

2 Likes

I see, but try fix the renderData() when the call succeeds and when it fails, along with the status that you are already printing on console, print the var middlewareUrl as well (if possible), then post the errors log here so we can try to help.

1 Like

Hi @yusrakhatri,

As @samuelpares mentioned, if you could add the error logs and print all the variables used in the request as well, we could try to help with the troubleshooting.

I’m not able to reproduce this issue with $request for a POST request. So, it’s not a common issue on our platform, I can confirm.

3 Likes

Apparently the same code is working fine now. Strange!
Thank you Ravi and Samuel for the help :slight_smile:

3 Likes

Guys, facing this issue again. this time I have managed to screenshot the response. Attaching here:

The same request through postman works fine.

@Raviraj, can you help me in this regard?

Hi, @yusrakhatri!

On your Postman request, it seems to have some different headers, it’s pointing to 10… what is there?
And looking at it now, something came to my mind about a similar issue I had, I think Postman was assuming that the content-type was application/json, as for the fdk request, it would not. So try to add a header on your code:

“Content-Type”: “application/json”

3 Likes

THIS WORKED!
Thanks Samuel. :slight_smile:

1 Like