Complicated http request help

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:

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:

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.

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

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
and the function which is used for this http request

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

i.e. start '{"fields":

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

1 Like