Pinterest HTTPS node - json body error

Describe the problem/error/question

I am trying to send a POST request to “Create a Pin” but the JSON body is not formatted properly.

This is documentation on the cURL for pinterest API:
https://developers.pinterest.com/docs/api/v5/#operation/pins/create

This is the HTTPS node I’m using (authentication is correct):

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

[
{
“id”: “0291155e-64ba-4d48-8590-6f58d669ac19”,
“name”: “7 ways to use AI”,
“property_publishing”: “AI”,
“property_type”: “type”,
“property_media”: [
https://prod-files-secure.s3.us-west-2.amazonaws.com/5390d420-4529-4fe6-9baa-5f84280642ae/8f8bb6b8-0f8e-4775-9670-302e2b6e32c1/47_OpenAI_announces_GPT_store_launching_next_week.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45HZZMZUHI%2F20240109%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20240109T151442Z&X-Amz-Expires=3600&X-Amz-Signature=1819a3d4c76e45725929ea5699261e5cabc3dfbf0144de11664745e73b8eb4ed&X-Amz-SignedHeaders=host&x-id=GetObject
],
“property_topic”: “AI”,
“property_sub_topic”: null,
“property_post_link”: null
},
{
“pinterestPin”: “This is a test \nThis is 21 2 \@pinterest\nThis is line 4\n• sdasadsd\n\nHi\n1. dfsjlkfjdsfl\n2. fdslkjlkdsjfldsf\n\n👋\nsklajdsakjhd\nhttps://www.pinterest\n\n\#pinterest\nd2323d\n\nIntroduction\nArtificial Intvdfnce \(AI\) has revolutionized numerous industries with its ability to perform tasks that traditionally required human intelligence. In recent years, AI has also made significant advancements in the creative field. From assisting with content creation to enhancing the overall creative process, AI”
}
]

Information on your n8n setup

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

Hey @pooria,

Just to check is the data coming out of the node before the http request the json data you have pasted as that has some issues it is 2 items but each item doesn’t contain all of the fields so on the second item run it would throw an error.

It looks like you may also need to tweak how you are sending the data as you are using an expression but without actually using an expression. The JSON in your example body is also showing as invalid on jsonlint.com it looks like board_id value is not properly quoted. It also looks like you are trying to send media_source as an array but the Pinterest docs show it as an object.

I would maybe try with something like the below and tweak from there.

Thx @Jon.

Guessing that works but you’re right the second json is throwing errors.

I’ll create a separate post for why that is

@Jon any tips on how to access the second item using JSON expressions?

Hey @pooria,

I think I have answered that one now :slight_smile: I am still catching up and we still have members of the support team on leave so it may take me a bit longer than normal to get to some posts.

1 Like

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