POST request with file in query parameters

Describe the issue/error/question

I have a workflow where I use the Edit Image node. I am then attempting to upload this to Publit.io. I see there are other question about how to send files with the HTTP module and a lot of those end up using axios or request-promise-native.

I think the challenge I’m having is I’m not sure any of those solutions will work, nor the ones using JSON Raw in the HTTP node when the file is sent as a query parameter.

Are there any options anyone can think of? I am not experience with axios or request-promise-native, so perhaps my investigating didn’t take me far enough.

I am attempting to use the Create File endpoint found here Publitio API Documentation & Reference

Also, is there a way to make suggestions for adding functionality to nodes? If the HTTP module had some functionality of the Read Binary File node, this would be fairly simple.

What is the error message (if any)?

Please share the workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 0.215.1
  • Database you’re using (default: SQLite): default
  • Running n8n with the execution process [own(default), main]: default
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi,

You should send the file in the body using “Form-Data” content type and “n8n Binary data” parameter type. I tested with Publit.io API and this work fine.

Here is the workflow with the HTTP node correctly set up:

Interesting result I am getting. I am getting an error "Input Data Field Name ‘data’ could not be found in input, but I can see it clear as day. Do you see anything obvious here?

Btw. I changed the URL call for the screenshot to hide the key.

I also changed the output in the Auth node such that the key in the return is called ‘data’ instead of ‘file’.

Can you show the output of your step “Edit Image”?

Absolutely. Here are the JSON and Binary outputs.

Screenshot 2023-02-17 at 10.10.52 AM

I just realized that if I move the Upload step right after the Edit Image step, then this works. I have concerns doing it this way since I would then need to put the Auth step before the Get Image Template step and the authorization is based on time. If I have a large file, the authorization could expire before we get to the upload step.

Sorry to respond 3 times…

If I do the following after the Edit Image step, console.log($(‘Edit Image’).all())

I get the following

Could you try with this in the Code node

This worked perfectly, and was such an obvious answer in hindsight. Always learning… Thank you for setting my straight!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.