Skip to main content
Question

Is there a better way to use the HTTPCaller for Multipart/ form data?


j.m-visma
Contributor
Forum|alt.badge.img+5

I am using the HTTPCaller to interact with an API, for that I use the setting Multipart/ Form Data. This is the way another user got the Endpoint to work for them and I just always used it. This works pretty well, the API does what I want, the connection is stable, but there is one problem. Sometimes it takes a lot of time to configure the Multipart-part.

For some jobs I need to configure dozens of parameters, this leads to a lot of typing, proofreading, etc.

 

For this particular endpoint I don't just need to give parameters about the object I want to edit (some inspection), but also something like a table definition. The row (row_id) and the value, for each attribute of my dataset. Since this API endpoint doesn't like it when I send in null values as values, I need to run several configurations of the same HTTPCaller one that drops each variation of Null values in the dataset.

 

Now I was wondering if I could somehow build the whole statement about the rows and their values with something in FME and then send the whole unit to the endpoint. Something like the JSONtemplater. Then I could just set that workflow up once and reuse it for different data. The JSONtemplater didn't work work for me. But who knows, maybe because I configured the Json wrong. Everything this API returns to me is in JSONs, it would make sense if it accepted them also. I think I would already be helped if I could see what exactly the HTTPCaller sends to my endpoint.

 

I would really appreciate any help you can give me!

2 replies

mark2atsafe
Safer
Forum|alt.badge.img+48

I don’t know the answer to your question - though I would be interested to find out the answer too - but I do know that you can turn on Log Debug under Tools > FME Options > Translation > Log Message Filter. If you do that, the log will show more information about what is being sent to/from the API. It may help you. Be aware that it might show some odd warnings and errors that are usually not important. Don’t worry about them.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+48

Actually, maybe I can help. You see this post here? I make those automatically using FME. I use the JSONTemplater to create JSON content and then the HTTPCaller to post that content to the API. It looks like this:

 

The main dialog is the JSON template that I use. It looks odd, but it’s because I’m putting HTML into it and I have to use special characters to avoid errors. The dialog that I posted on top is from my HTTPCaller. I use “Specify Upload Body” and point to the attribute containing the JSON template.

What I’m unsure about is whether you can switch from multi-part upload to specify upload body. I’m just not sure if that’s possible in general or in your scenario in particular. If it is, then this might be a good solution.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings