OK they are quick to respond:
"You need to use your API key as Username and x as password under basic authentication."
I used this and still got the error that only one auth mechanism allowed..
They responded:
"We are not sure if NodeRED supports the end point URL provided by us."
Of which I asked for a Curl example.
so copy the working request as a cURL from postman: php - Converting a Postman request to curl - Stack Overflow
Be sure to sanitise it before posting
Also, use the forum </>
code button before sending.
EDIT...
But first, try adding those headers to node-red HTTP-Request.
If their server is standards compliant, I can pretty much guarantee node-red can do this.
curl --location --request GET 'https://company.freshservice.com/api/v2/analytics/export?id=xxx-3344xxxkkk' \
--header 'Authorization: Basic XX=='
did you delete the password? Basic XX==
looks like you did.
Would be better to take the working postman, change the password to something like bad_pass
then export it.
curl --location --request GET 'https://company.freshservice.com/api/v2/analytics/export?id=Long-ID-KEY-With-88882222-Numbers' \
--header 'Authorization: Basic YmFkX3Bhc3M6c2VudA=='
Before I translate this, I forgot to ask, have you tried the cURL command in a terminal window (not powershell) Ideally from a linux box/PI/wsl instance
Yes using the exact command from postman I was able to collect data in the terminal of the nodered system
Can you try this...
[{"id":"145be34f3883da89","type":"inject","z":"ccdc4f1f78201a08","name":"Click me","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":360,"y":640,"wires":[["bbcb4f6127d457d8"]]},{"id":"bbcb4f6127d457d8","type":"function","z":"ccdc4f1f78201a08","name":"","func":"//original curl: \n//\n//curl --location --request GET 'https://company.freshservice.com/api/v2/analytics/export?id=xxx-3344xxxkkk' \\\n//--header 'Authorization: Basic XX=='\n\nmsg.method = \"get\";\nmsg.url = \"https://company.freshservice.com/api/v2/analytics/export?id=xxx-3344xxxkkk\";\nmsg.payload = ``;\nmsg.headers = {\n \"Authorization\": \"Basic XX==\" //CHANGE XX== TO WHAT POSTMAN SENDS\n //Add other headers postman sends if necessary\n};\nmsg.cookies = null;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":640,"wires":[["c423adfebdc95cdd"]]},{"id":"c423adfebdc95cdd","type":"http request","z":"ccdc4f1f78201a08","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":720,"y":640,"wires":[["144e9139f50e8e6d"]]},{"id":"144e9139f50e8e6d","type":"debug","z":"ccdc4f1f78201a08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":640,"wires":[]}]
Be sure to update the function node as per the comments inside
Did you "unset" the auth in the http-request node ?
Yes there is no auth in the HTTP request mode.
For anyone following along: I have been looking at this with @sourceminer privately and it seems the issue is related to the HTTP-Request node failing to follow redirects!
This works if you operate the "Manually follow redirects" inject...
Demo flow (URL and Auth will need to be set in the Set URL
function)...
[{"id":"145be34f3883da89","type":"inject","z":"ccdc4f1f78201a08","name":"Follow Redirects (default)","props":[{"p":"followRedirects","v":"true","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":570,"y":580,"wires":[["bbcb4f6127d457d8"]]},{"id":"c423adfebdc95cdd","type":"http request","z":"ccdc4f1f78201a08","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Accept","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""}],"x":800,"y":640,"wires":[["e61cbdf8ca902fad"]]},{"id":"144e9139f50e8e6d","type":"debug","z":"ccdc4f1f78201a08","name":"redirected response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1500,"y":640,"wires":[]},{"id":"bbcb4f6127d457d8","type":"function","z":"ccdc4f1f78201a08","name":"Set URL","func":"\nmsg.method = \"get\";\nmsg.url = \"https://test_my_api.com/api/v1/info\";\nmsg.payload = ``;\nmsg.headers = {\n \"Authorization\": \"Basic XXX\" //Set XXX Accordingly\n //Add other headers if necessary\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":640,"wires":[["c423adfebdc95cdd"]]},{"id":"e61cbdf8ca902fad","type":"switch","z":"ccdc4f1f78201a08","name":"200? \\n 302 \\n otherwise","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"},{"t":"eq","v":"302","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":960,"y":640,"wires":[["63c8b43605bbc35e"],["16ababd4a0963ee7"],["14e464e951c2313e"]]},{"id":"63c8b43605bbc35e","type":"debug","z":"ccdc4f1f78201a08","name":"direct response","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1480,"y":580,"wires":[]},{"id":"14e464e951c2313e","type":"debug","z":"ccdc4f1f78201a08","name":"fail!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1450,"y":700,"wires":[]},{"id":"867f4d6102286c40","type":"http request","z":"ccdc4f1f78201a08","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Accept","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"Content-Type","keyValue":"","valueType":"application/json","valueValue":""},{"keyType":"Location","keyValue":"","valueType":"msg","valueValue":"headers.location"}],"x":1310,"y":640,"wires":[["144e9139f50e8e6d"]]},{"id":"16ababd4a0963ee7","type":"function","z":"ccdc4f1f78201a08","name":"follow redirect","func":"msg.url = msg.headers.location\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":640,"wires":[["867f4d6102286c40"]]},{"id":"9ee8a6ecac185a61","type":"inject","z":"ccdc4f1f78201a08","name":"Manually Follow Redirects","props":[{"p":"followRedirects","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":570,"y":700,"wires":[["bbcb4f6127d457d8"]]}]
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.