Call Gemini API with PDF - JSON parameter needs to be valid JSON

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

JSON parameter needs to be valid JSON

Information on your n8n setup

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

Followed this instruction to set up,
the original JSON was which works on version 1.105.2 :
{
“contents”: [
{
“parts”: [
{
“inline_data”: {
“mime_type”: {{ $(‘Google Drive Trigger’).item.json.mimeType }},
“data”: {{ $json.data }}
}
},
{
“text”: “extract the data”
}
]
}
]
}
changed the JSON to below but still not working:
={
“contents”: [
{
“parts”: [
{
“inline_data”: {
“mime_type”: $(‘Google Drive Trigger’).item.json.mimeType,
“data”: $json.data
}
},
{
“text”: “extract the data”
}
]
}
]
}

Please help!

What’s your question @CH_Tai

Welcome to the community

Hi there, can you tell me the data type of this $json.data, is it a pdf turn to base64 or what?

i think we need to check on that a little bit deeper since i think either that value or other dynamic value that you put tht makes the error invalid JSON

maybe there’s a typo, or you need to wrap them in a “ “, or you forgot to put a comma, etc.

i would suggest for you to copy the json where the dynamic data is already filled, and paste it in this website to validate if it’s a valid json or not

hope this helps, thank you!

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