0

I am lost recreating curl POST request in node red. My bank API documentation requires to form request like this:

multipart/form-data

curl -S -s --cacert GeoTrust_Primary_CA.pem -X POST -F "type=xml" -F "token=aGEMQB9Idh35fxxxxxxxxxxxxxQwyGlQ" -F "file=@C:\davka.xml" https://www.fio.cz/ib_api/rest/import/> result.xml 2>errorlog.txt type errorlog.txt

I really need just

curl -X POST -F "type=xml" -F "token=aGEMQB9Idh35fxxxxxxxxxxxxxQwyGlQ" -F "file=@C:\davka.xml" https://www.fio.cz/ib_api/rest/import/

However I am not able to pass the token to the form.

still get Required String parameter 'token' is not present

I failed with prefered http request or many node-red-contrib-send-form(...) variations.

My flow:

[{"id":"f0c84434.8907a8","type":"fileinject","z":"6012893b.689db8","name":"/share/result.xml","x":220,"y":300,"wires":[["690ae5f4.37b66c"]]},{"id":"690ae5f4.37b66c","type":"function","z":"6012893b.689db8","name":"","func":"msg.headers = {\n "content-type" : 'multipart/form-data'\n };\nlet databuffer = msg.payload;\n\nmsg.payload = {\n "KEY": {\n "value": databuffer,\n "options": {\n "filename": "data.xml",\n "type": "xml",\n "token": "aGEMQB9Idh35fxxxxxfakexxxxxxxxQwyGlQ"\n }\n }\n}\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":220,"wires":[["6cca79ea.a45f28"]]},{"id":"6cca79ea.a45f28","type":"http request","z":"6012893b.689db8","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://www.fio.cz/ib_api/rest/import/","tls":"","persist":false,"proxy":"","authType":"","x":760,"y":220,"wires":[["8ec9dd16.83be","3f347cc6.b9a114"]]},{"id":"8ec9dd16.83be","type":"debug","z":"6012893b.689db8","name":"File has been sent","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":220,"wires":[]},{"id":"ba973765.11aa88","type":"inject","z":"6012893b.689db8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":220,"wires":[["e75f0fb7.fa71b"]]},{"id":"e75f0fb7.fa71b","type":"file in","z":"6012893b.689db8","name":"","filename":"/share/result.xml","format":"","chunk":false,"sendError":false,"encoding":"none","x":360,"y":220,"wires":[["690ae5f4.37b66c"]]},{"id":"3f347cc6.b9a114","type":"debug","z":"6012893b.689db8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"statusCode","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":280,"wires":[]}]

1 Answer 1

1

You should be able to do this with the core HTTP Request node. The issue is the format of the payload you are passing it.

If you change your Function node to structure the payload like this, I believe you should get further:


msg.payload = {
    "file": {
        "value": databuffer,
        "options": {
            "filename": "data.xml",
        }
    },
    "type": "xml",
    "token": "aGEMQB9Idh35fxxxxxfakexxxxxxxxQwyGlQ"
}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.