I was hopeing some RESTful node (in particular POST) experts can help me out here:
When using Postman to execute a POST to an API, everything works fine -
I am using a token for authentication in the header, a json string in the body. Also in the body, I upload a file (which is then used by the system I access). Postman offers a file-select dialogbox, there is not "string" one can view to see how it translates (at least I can't find anything of that sort).
Now if I want to do this within Knime I am not sure how to pass the file.
A test passing a JSON string for a case where I don't require a file works fine. But for cases when I want to refer to a file - I am not sure how.
In Postman it looks like there are two body portions, whereas the Knime node only has one body portion.
Any suggestions?Â
(PS: I am not an expert in RESTful or JSON, I usually "make it work" though.)
This is complicated... The request still has just one body but consists of different parts. These types of request require a special encoding of the request body (e.g. multipart/form-data). Technically you can construct the correct encoding with a couple of pre-processing nodes but I suspect this gets quite complicated. Maybe someone from the forum takes this challenge and shares the results.
We have a node that takes several columns and creates an encoded request body on our list, however the list is long...
We have a "Multipart" node in Palladian (warning: usage it not quite straight forward ... feel free to get back in the Palladian sub forum). But you'll have to use the HttpRetriever then, instead of the REST nodes.
@thor - which node do you have in mind for such a construction (several columns->encoded request body)? Or did you mean by "on our list" that it is under construction?
@qqilihq - I'll have a look at Palladian, but, yes, I remember from a past scenario that it isn't straightforward..
I was wondering if there is any update on this topic. I just tried to upload a file to a third party REST api using the post node. I would either use the body to enter somehow the local path of the file I want to send or I use the binary code of the file as body. Both versions did not work for me and maybe there is a solution in place nowadays using the POST node.
You can simply supply an Authorization header with the needed token – therefore create a column in the input table called Authorizationm which contaisn a string value such as Bearer XXXX and select this in the Headers tab within the configuration. Voilà !
If you still have trouble, don’t hesitate to get back with a sample workflow!
I added a Table Creator (node 31) and cross-joined it to add it to the row. This contains a string as follows:
|Authorization|
|—|—|
|Bearer 7QqredactedB|
Here’s what it looks like, and you can see the url, and the Authorization string in the Spec. Note the Node returned an error when ran.
A 400 Bad Request error happens **when a server cannot understand a request that’s been made of it
I have been successful in using the API for POSTing rows to the spreadsheet using the POST Request node, but I don’t think that supports file uploads (if it does, let me know!)
I’d guess that the authentication is fine and properly set up (otherwise you’d get a different error code), but the data you send is not structured properly.
I noticed that you kept the JSON data from the example workflow, which is just there for figurative purposes. You’ll likely need to adapt it to the Smartsheet API so that it contains the data you want to send with the request. (see the “Table Creator” node with the comment “Define some data to submit as JSON format”).
Good catch! It did help a little. I had neglected that node.
Since I didn’t need it, I removed the cross-join that connects it in, and removed the JSON from the 2nd line of the Multipart Entity Creator’s “input column”, but that didn’t help.
I still got a 400 error without this additional JSON.
Perhaps I’ll revisit this at a later date when I have a little more experience under my belt. Thanks again!
AJ