Hello, I’m not sure this is the right place to ask, but I’m struggling uploading a microservice file throught node-red. I’m doing a POST request to /application/applications/someId, but I get error 500 :
{"error":"general/internalError","message":"Provider not found","info":"https://www.cumulocity.com/guides/reference-guide"}"
It is probably due to my struggle do send a multipart form, but it is not verbose enough to understand what I did wrong…
I’m doing the multipart split that way :
// The file contents (Buffer) from previous node
var fileBuffer = msg.payload;
msg.method = "POST";
msg.headers = {
"content-type" : 'multipart/form-data'
};
msg.payload = {
"KEY": {
"value": fileBuffer,
"options": {
"filename": "archive.zip"
}
}
}
return msg;
Best regards,
Paul
Hi @paul.de-la-porte-des,
it seems you are using the wrong API in case you are trying to update the binary of an application. For that case you POST request should go to /application/applications/{id}/binaries (see: Cumulocity - OpenAPI).
Regards,
Tristan
2 Likes
Oh it is a mistake, I’m using /application/applications/{id}/binaries
Three things to try:
- Use application/zip as the content-type
- Include an Accept: application/json header
- For the filename use the name of the microservice
Otherwise opening a support ticket can help to get somebody to look at the logs.
Have you configured your file reading node to actually output a buffer?
Having that set in combination with:
const fileBuffer = msg.payload;
const filename = msg.filename;
msg.method = "POST";
msg.headers = {
"content-type" : 'multipart/form-data',
"accept": "application/json"
};
msg.payload = {
"file": {
"value": fileBuffer,
"options": {
"filename": filename
}
},
"fileName": {
"value": filename
}
}
return msg;
Works just fine on my end..
1 Like
I found the issue, the code works great, it is my file node that returned an error code for some unrelated reason, and I did not check for errors, so the binary was in fact my error code… Thanks a lot for confirming that the code snippet worked great, It helped me a lot. Have a nice day
1 Like