Invalid JSON when sending content generated by OpenAI to WordPress

Status: Closed · Asked by PRPA on · 0 views

PRPA — Question ·

Hi,

I have set a Pabbly Connect automation to create text using OpenAI and then send this text to my WordPress site.

I have seen this video:

youtube.com/watch?v=-4RvyDw3cFU

And I have set up everything accordingly and everything seems to be running fine... apart from the fact that WordPress does not want to received the text created by OpenAI due to a JSON issue:

The response received from the WordPress step in the autiomation is shown below:

Code: rest_invalid_json
Message: Invalid JSON body passed.
Data Status: 400
Data Json Error Code: 3
Data Json Error Message: Control character error, possibly incorrectly encoded

I understand that this means that there are some characters in the content created by OpenAI that are in conflict with JSON and thus I have to remove them.

I read about a similar issue at https://forum.pabbly.com/threads/json-error-while-trying-to-connect-to-wordpress-and-post.8927/, where you suggested using the Text Formatter and search/replace function.

But this would have to be done for all JSON special characters, https://www.tutorialspoint.com/json_simple/json_simple_escape_characters.htm

I also read the solution to include a Text Formatter HTML > Markdown at https://forum.pabbly.com/threads/remove-json-control-characters.5910/, but when I tried that, it didn´t work: WordPress did not wan to accept the incoming text due to "content empty".

So my question is: How do I accept data from OpenAI that includes the JSON special characters (quotation marks, etc.)?

PRPA — Reply ·

The title of my automation ends with 689841981498148918, if you want to have a look.

Pabblymember11 — Reply ·

Hey @PRPA
In the Category ID, Tag, and Featured Media Id you need to pass the individual's ID from WordPress.

Whereas to pass the tag Id in the fields, you can use the "Search Tag" action step of WordPress in your workflow to give the Id dynamically.

PRPA — Reply ·

That worked, solved, thank you!

Back to all forum threads · Log in to reply