Convert working curl command into Node-Red flow

I have a working curl command I'm trying to integrate into Node-Red. I have a Change node in front of a HTTP request node, but I'm stuck trying to figure out the correct formatting required.

Here's the curl command -

curl  -X POST -H "Host:prod.zodiac-io.com" -H "accept:application/json" -H "content-type:application/json" -H "accept-encoding:gzip" -H "user-agent:okhttp/3.12.0" -d '{"api_key":"XXXYYYZZZ", "email":"myemail@gmail.com", "password":"AAABBBCCC"}' "https://prod.zodiac-io.com/users/v1/login"

Try

[{"id":"71868977.626ca8","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"https://prod.zodiac-io.com/users/v1/login","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"api_key\":\"XXXYYYZZZ\",\"email\":\"myemail@gmail.com\",\"password\":\"AAABBBCCC\"}","tot":"json"},{"t":"set","p":"headers","pt":"msg","to":"{\"Host\":\"prod.zodiac-io.com\",\"accept\":\"application/json\",\"content-type\":\"application/json\",\"accept-encoding\":\"gzip\",\"user-agent\":\"okhttp/3.12.0\"}","tot":"json"},{"t":"set","p":"method","pt":"msg","to":"POST","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":3240,"wires":[["777cffff.503dc"]]}]
1 Like

Perfect! Thank-you.

The curl command returns the data I need in Node-Red now. Unfortunately it appears to crop the token I'm attempting to grab. The following screen-shot shows the full token I'm expecting (about 1700 characters), and the next block is the token returned in Node-Red.

The Node-Red data has about 2/3rds of the characters of the correct token and ends with ..."

Is there a limit on characters in a given JSON field?

I need to flow the IDToken to an MQTT node for another process. Any suggestions?

Screen-shot of IDToken clipping

are you saying it is clipped because it doesn't show in the debug log? If so, the debug log clips the output IN THE LOG based on a setting in settings.js however the value in the msg should be still there

If you are saying mqtt is clipping the data when you publish it, this link might shed some light on the issue:

1 Like

It's just clipping in the debug log. That's reassuring that the value should be there because I haven't worked out how to forward the token to an MQTT node yet (call me a complete noob....).

When I 'copy Path' for the relevant token in the debug log, I see -

payload.userPoolOAuth.IdToken

You can use a change node to move payload.userPoolOAuth.IdToken to payload

Thanks @zenofmud . All working well now.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.