How to send a PNG for background removal API (PhotoRoom)

Describe the problem/error/question

When running the flow and doing a POST request to the endpoint I get back:
“ERROR: Cannot create property ‘x-api-key’ on string ‘form-data; name=“image_file”; filename=Webbplats1_2023-08-12 15:13:05.png’”

What is the error message (if any)?

“ERROR: Cannot create property ‘x-api-key’ on string ‘form-data; name=“image_file”; filename=Webbplats1_2023-08-12 15:13:05.png’”

Please share your workflow

API Reference

Share the output returned by the last node

Stack

TypeError: Cannot create property 'x-api-key' on string 'form-data; name="image_file"; filename=Webbplats1_2023-08-12 15:13:05.png'
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V2/HttpRequestV2.node.js:833:61)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:646:28)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:631:53

Information on your n8n setup

  • n8n version: 1.0.4
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: n8n cloud

Hi @Profit_Media :wave: This sounds like you’re not sending over the API token correctly. Can you take another look at your authentication settings? (Please don’t post screenshots with those details here :see_no_evil: Or you’ll need to rotate all your keys! )

Hmm

the value is formatted without bearer exacly as:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi @Profit_Media - I more meant details that might contain the api key value :sweat_smile:

Did you try to edit the value there and double check the API key is correct?

Thank you for your quick reply, yes, checked it like 34 times.

It works in the playground

but n8n gives

image


So I just signed up for an account to see if I could successfully make a request, and had no problems doing so with this workflow:

You might be using an older version of the HTTP Request node - Photoroom’s API suggests sending the binary data in the image_file field, which your version of the node won’t let you specify.

In a more recent version of the node, you can specify the Form Data, like so:

Which then gives you a successful request :smiley: Can you try either using the workflow I posted as a base, or maybe remove the current HTTP node you have and re-add it through the node menu (instead of copying and pasting from an older workflow)? That might fix this up!

2 Likes

You did it !

It was the data part that did it because now it’s working with the same saved credentials.

Somehow the GET account info isnt still working but the task is accomplished. Thank you!

1 Like

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