Node-red flows update using cURL

Home Forums Conduit: AEP Model Node-red flows update using cURL

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23429
    Benjamin Ning
    Participant

    Hello.

    I have a MTCDT-H5-210A-US-EU-GB running firmware 1.4.14 which has node-RED version 0.15.3.

    I’ve been trying to update the node-RED flows using cURL commands as a way of investigating whether I can update the flows remotely. I have managed to get only so far before hitting a wall.

    I use the following command whilst SSHing into the Conduit to receive my access token:

    curl -k https://localhost:1880/auth/token –data ‘client_id=node-red-admin&grant_type=password&scope=*&username=admin&password=password’ -v

    (substituting my actual username and password).

    I use the -k modifier to do so insecurely as there is something up with the conduits certificates (I don’t pretend to understand certificates but if someone could let me know how to fix this I would be very grateful).

    I then use the access token in the command below, and this should update my flows:

    curl -X POST -k https://localhost:1880/flows -H “Content-Type: application/json” -H “Node-RED-Deployment-Type: full” -H “Node-RED-API-Version: v2” -H “Authorization: Bearer *********” –data @”http://www.examplesite.co.uk/flows.json” -v

    The ********* represents the access token, and the examplesite url represents where I uploaded the flows.

    However upon running the command I get the following error:

    < HTTP/1.1 400 Bad Request
    < X-Powered-By: Express
    < Content-Type: application/json; charset=utf-8
    < Content-Length: 93
    < ETag:
    < Date: Thu, 10 May 2018 01:28:14 GMT
    < Connection: keep-alive
    * HTTP error before end of send, stop sending
    <
    * Closing connection 0
    {“error”:”unexpected_error”,”message”:”TypeError: Cannot call method ‘forEach’ of undefined”}

    (I’ve removed the ETag as I’m not sure if that contains sensitive data or not).

    This seems to be an error within my flows.json file? I obtained this file by using PuTTYs pscp.exe to transfer the flows.json file from the conduit from the following location:

    /var/config/app/install/development/flows.json

    This appears to be my active flow file.

    Can anyone assist?

    Many thanks,

    Ben.

    • This topic was modified 5 years, 11 months ago by Benjamin Ning.
    • This topic was modified 5 years, 11 months ago by Benjamin Ning.
    #23434
    Benjamin Ning
    Participant

    After a bit more playing this morning I have discovered where I was going wrong. Two errors, one of which was due to my unfamiliarity with cURL.

    So you can’t pass the cURL command a URL for retrieve the data, it has to be done in two steps, which can be entered in one command as below:

    curl http://www.examplesite.co.uk/flows.json | curl -X POST -k https://localhost:1880/flows -H “Content-Type: application/json” -H “Node-RED-Deployment-Type: full” -H “Node-RED-API-Version: v1” -H “Authorization: Bearer ********” –data @- -v

    Also I thought my Node-RED_Version type was v2, but in fact it was v1.

    Hope this helps someone else out.

    Ben.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.