You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Post request to API returns Response code 500 (Internal Server Error)
Node.js version: 16.20.2
OS & version: Rocky Linux 8.9 (Redhat)
I have an API written in C# .NET. One of the endpoints allows users to unsubscribe from emails and does not return any json response.
When using CURL or Postman, the API returns a 200 status code. GOT returns a 500 server error. On the web server itself, I see the following in logs:
Line 105662: 2024-02-15 09:26:14 10.52.1.9 POST /Tapier/api/TapierSubsciption/Subscribe isUnsubscribe=true&email_id=someemailid&healthcheck=1 443 - 10.52.1.211 got+(https://github.com/sindresorhus/got) - 500 0 0 307
Line 200535: 2024-02-15 16:40:19 10.52.1.9 POST /Tapier/api/TapierSubsciption/Subscribe isUnsubscribe=true&email_id=someemailid&healthcheck=1 443 - 10.52.1.211 PostmanRuntime/7.36.1 - 200 0 0 985
I am unable to upgrade to a more recent version of nodejs as the host is outside of our control.
I can confirm the issue also occurs on Nodejs 18 and Nodejs 20 in [email protected].
Actual behavior
The following error is reported after running the script:
HTTPError: Response code 500 (Internal Server Error)
at Request.<anonymous> (file:///home/vagrant/samplenodejs/node_modules/got/dist/source/as-promise/index.js:86:42)
at Object.onceWrapper (node:events:628:26)
at Request.emit (node:events:525:35)
at Request._onResponseBase (file:///home/vagrant/samplenodejs/node_modules/got/dist/source/core/index.js:604:22)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Request._onResponse (file:///home/vagrant/samplenodejs/node_modules/got/dist/source/core/index.js:646:13) {
input: undefined
Expected behavior
Curl and Postman both return 200 status codes. Expecting the same from GOT.
Code to reproduce
The API endpoint in the sample is an non-working example but the rest of the code is valid.
The text was updated successfully, but these errors were encountered:
marketier
changed the title
Post request to API returns Response code 500 (Internal Server Error) whereas CURL returns 200 status code
Post request to API returns response code 500 (Internal Server Error) whereas CURL returns 200 status code
Feb 19, 2024
Hi @marketier, I don't think it's an issue with Got itself, but with your API server: 500 status code reflects an issue on server side.
The best way you could investigate it is to check API server debug-level logs while doing requests from Got. Hopefully, those logs will contain more information about the reasons why it can't process requests received from Got.
If you don't have an access to the server logs, or they are not descriptive enough, you could go other way:
Write down all request properties that Got has sent to the server (i.e. headers, search params, etc)
Send a request with the same params from Postman/CURL and check if it fails as well (it apparently will)
By removing the properties one-by-one, find that one which causes the error.
For example, from your server logs it's clear that User-Agent header sent by Postman is set to PostmanRuntime/7.36.1, but the same header sent by Got is set to got+(https://github.com/sindresorhus/got) — try staring with this information, maybe even this particular header causes some issues on API server side.
Post request to API returns Response code 500 (Internal Server Error)
I have an API written in C# .NET. One of the endpoints allows users to unsubscribe from emails and does not return any json response.
When using CURL or Postman, the API returns a 200 status code. GOT returns a 500 server error. On the web server itself, I see the following in logs:
I am unable to upgrade to a more recent version of nodejs as the host is outside of our control.
I can confirm the issue also occurs on Nodejs 18 and Nodejs 20 in [email protected].
Actual behavior
The following error is reported after running the script:
Expected behavior
Curl and Postman both return 200 status codes. Expecting the same from GOT.
Code to reproduce
The API endpoint in the sample is an non-working example but the rest of the code is valid.
The text was updated successfully, but these errors were encountered: