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].
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
Curl and Postman both return 200 status codes. Expecting the same from GOT.
The API endpoint in the sample is an non-working example but the rest of the code is valid.
import got from 'got';
const url = 'https://api.domain.my/TapierService/api/TapierSubsciption/Subscribe?isUnsubscribe=true&email_id=someemailid&healthcheck=1';
const options = {
body: '[{"subscription_url": "","event": ""}]',
headers: {
'Content-Type': 'application/json'
},
};
const data = await got.post(url, options);
...
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too