<Response [422]> "error":"Unprocessable Entity" when trying to create_many dynamic content variants | Community
Skip to main content

<Response [422]> "error":"Unprocessable Entity" when trying to create_many dynamic content variants

  • September 21, 2021
  • 3 replies
  • 0 views

Willie

Hi, 

We're trying to add language variants to a dynamic content item that has already been created. Using the following endpoint and data: 

api/v2/dynamic_content/items/1900000084307/variants/create_many.json 
 
{"variants": [{"locale_id": 66, "active": True, "default": False, "content": "تجربة"}]}
 
We get the following response from the server: 
 
<Response [422]> {"error":"Unprocessable Entity","message":"Server could not parse JSON"}
 
Can anyone help point us in the right direction?
 

3 replies

Eric27
  • September 22, 2021

Hey Willie,

Having your boolean's capitalized on "active" and "default" isn't valid json. If you switch those to lowercase you should be all set.

Have a wonderful day!

Eric Nelson | Manager - Developer Advocacy


Willie
  • Author
  • September 22, 2021

Thanks Eric! That was exactly what I needed.

For any future readers:

In python, I was using json.loads() on a formatted string, which capitalized the boolean values, and tried to pass that as data to the post function. Passing the string in directly did the trick.


  • May 26, 2023

Hi, I am receiving the same [422] error for a few weeks now, the json looks like this: 

{"ticket":
{% assign has_attachment = false %}
{% for comment in ticket.comments %}
{% if comment.attachments.size > 0 %}
{% assign has_attachment = true %}
{% endif %}
{% endfor %}
{% if has_attachment %}
{"additional_tags":["attachments_yes"], "remove_tags": ["attachments_no"]}
{% else %}
{"additional_tags":["attachments_no"]}
{% endif %}

Could you help me out please? Thx!