Home > Software engineering >  Postman works, but the "Code snippet" generated no. cURL
Postman works, but the "Code snippet" generated no. cURL

Time:08-22

From my computer the query via postman to my endpoint works, it returns the expected result. but the code generated by "code snippet" does not work, what could be the cause ?

--That code doesnt work. But in postman yes (same laptop)

curl --location --request POST 'https://service' \
--header 'Ocp-Apim-Subscription-Key: myKey' \
--header 'Content-Type: audio/mpeg' \
--data-binary '@/path/audio_test.mp3'

Error: curl: (28) Failed to connect to <service> port 443: Timed out

To check that it is not a problem with my end, I tried another service that works in postman and the code generated by postman through "code snippet" works as well.

-- That works in postman and in my consol --

curl --location --request POST 'https://´service' \
--header 'Key: myKey' \
--header 'Content-Type: application/json' \
--data-raw '{"text":"myText",
"language": "en"
}
'

its return the expected result

Does anyone have any idea where I could look? Thanks

CodePudding user response:

curl: (28) Failed to connect to port 443: Timed out

This will likely be a connection error either due to the client context (application/terminal) or the client host (the device itself). I assume the second request doesn't try to hit the same location or it was ran from another context.

Check your connection first and then troubleshoot from your way up. To do so, in the same exact place you're running your curl run the following:

telnet service 443

Where service is the endpoint you are using in the request. If that still gives the same error then the issue is down to a networking problem. Check from other clients, check VPNs or other applications that could be causing the blockage.

  • Related