# Convert working curl command into Node-Red flow

**URL:** <https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927>\
**Category:** General\
**Created:** [28 October 2020 04:50 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927 "2020-10-28T04:50:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [28 October 2020 04:50 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/1 "2020-10-28T04:50:20Z")

</div>

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 -

```auto
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"

```

> **[Post Request.png](https://drive.google.com/file/d/1krRRtoB7CqlOL6sf_1E8HnKNja4jR_nN/view?usp=sharing)**
>
> Google Drive file.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 October 2020 07:16 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/2 "2020-10-28T07:16:51Z")

</div>

Try

```auto
[{"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"]]}]

```

---

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [28 October 2020 07:34 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/3 "2020-10-28T07:34:44Z")

</div>

Perfect! Thank-you.

---

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [28 October 2020 08:07 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/4 "2020-10-28T08:07:04Z")

</div>

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](https://drive.google.com/file/d/1pa1eW3tvaBVR-GrB2das04HgrA_Gqit0/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2020 08:27 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/5 "2020-10-28T08:27:58Z")

</div>

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:

> **[MQTT Client and Mosquitto Broker Message Restrictions](http://www.steves-internet-guide.com/mqtt-broker-message-restrictions/)**

---

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [28 October 2020 08:58 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/6 "2020-10-28T08:58:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2020 09:04 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/7 "2020-10-28T09:04:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@Tico](https://discourse.nodered.org/u/Tico)\
**Post date:** [28 October 2020 12:48 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/8 "2020-10-28T12:48:37Z")

</div>

Thanks @zenofmud . All working well now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 November 2020 12:48 UTC](https://discourse.nodered.org/t/convert-working-curl-command-into-node-red-flow/34927/9 "2020-11-11T12:48:44Z")

</div>

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