# Complicated http request help

**URL:** <https://discourse.nodered.org/t/complicated-http-request-help/10330>\
**Category:** General\
**Created:** [18 April 2019 11:38 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330 "2019-04-18T11:38:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [18 April 2019 11:38 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330/1 "2019-04-18T11:38:14Z")

</div>

Hi, I have an account with ibm where I use node red and some other services. One is a machine learning where you can use cURL commands to access models. First it requires you to get a token and then you can post to the model for scoring inputs. But the cURL command is a little complex for me to find a way to fully integrate it into node-red.

To Recieve the token:

```auto
curl --basic --user $WML_SERVICE_CREDENTIALS_USERNAME:$WML_SERVICE_CREDENTIALS_PASSWORD $WML_SERVICE_CREDENTIALS_URL/v3/identity/token

```

I tried use the dropdown menu for the username and password given in the service credentials, but the password keeps getting shortened down when I deploy.

To Post:

```auto
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Authorization: Bearer $WML_AUTH_TOKEN" -d '{"fields": ["VIOLATION_CODE", "VIOLATION_STATUS", "INSPECTION_CATEGORY", "PROPERTY_GROUP", "LATITUDE", "LONGITUDE", "DEPARTMENT_BUREAU"],"values": [$ARRAY_OF_VALUES_TO_BE_SCORED, $ANOTHER_ARRAY_OF_VALUES_TO_BE_SCORED]}' https:xxxxxx

```

I don't know how to exactly setup the headers for the command above, like the input array to be scored, or fields header. Again if I use the "Bearer" authentication from the dropdown menu, a given token(from command window) is being cut and therefore I can't access the model.

Any guide is appreciated. I saw some examples with setting up headers, but they were pretty basic compared to what I need.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [18 April 2019 11:44 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330/2 "2019-04-18T11:44:08Z")

</div>

Did you see the example in the cookbook? [https://cookbook.nodered.org/http/set-request-header](https://cookbook.nodered.org/http/set-request-header)

---

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [18 April 2019 13:49 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330/3 "2019-04-18T13:49:48Z")

</div>

Yeah I tried it and it's helpful. It atleast allowed me to get the token part. But the second curl, how/where do I enter the fields and arrays. BTW the password issue was because node-red seems to need the passwords saved to keep it there. I'll include the code output for the post curl. ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d33650b6051fde098c391f0d6270f262b9e1eacc.png)  
and the function which is used for this http request

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/da7141c4ac1fd79d361168d7770ae3927968b9f6.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [18 April 2019 13:59 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330/4 "2019-04-18T13:59:50Z")

</div>

Your msg.payload isn't JSON. I would imagine your msg.payload should be the bit after the -d

i.e. start `'{"fields":`

---

<div class="post-metadata">

**Author:** ![DillonW](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@DillonW](https://discourse.nodered.org/u/DillonW)\
**Post date:** [18 April 2019 14:03 UTC](https://discourse.nodered.org/t/complicated-http-request-help/10330/5 "2019-04-18T14:03:02Z")

</div>

yes, I made it similar to the header style and used fields and values as object names. It works, thanks
