Why does posting an article with multiple HTML tags cause a bad request?

I am trying to publish an article with admin api. But getting bad request even though my access_token and api format is correct.

Having body_html in multiple html tags is getting bad requests :

{“article”:{“title”:“Its easy to see why so many people love”,“body_html”:"> > Test publish my article> > Test publish my article> > test test test> > "}}

Getting success if remove html tag:

{“article”:{“title”:“Its easy to see why so many people love”,“body_html”:"> > Test publish my article Test publish my article test test test> > "}}

Is there any way to publish my given format?

Hi,

Just html encode the contents of the body_html and it should work

Thanks for your reply . But I still faced the same.
This is my request

{“article”:{“title”:“Its easy to see why so many people love”,“body_html”:“”

this is heading1</h2>\n

add space after that line</p>\n

 </p>\n

 </p>\n

<span
style="font-size: 32px;">this is paragraph</span></p>“”,“metafields”:[{“key”:“title”,“value”:“as”,“type”:“single_line_text_field”,“namespace”:“global”},{“key”:“description”,“value”:“as”,“type”:“single_line_text_field”,“namespac
e”:“global”}]}}

and this is my code

sageseo_2-1659021214247.png

Thanks for your reply . But I still faced the same.
This is my request

{“article”:{“title”:“Its easy to see why so many people love”,“body_html”:“”

this is heading1</h2>\n

add space after that line</p>\n

 </p>\n

 </p>\n

<span
style="font-size: 32px;">this is paragraph</span></p>“”,“metafields”:[{“key”:“title”,“value”:“as”,“type”:“single_line_text_field”,“namespace”:“global”},{“key”:“description”,“value”:“as”,“type”:“single_line_text_field”,“namespac
e”:“global”}]}}

sageseo_3-1659021316699.png

and this is my code

sageseo_4-1659021316992.png

Hi,

You are missing the blog_id on which the article needs to be created, ref

Thanks . But my request url has blog id

Request article body:

{“article”:{“title”:“Its easy to see why so many people love”,“body_html”:“”

this is heading1</h2>\n

add space after that line</p>\n

 </p>\n

 </p>\n

<span
style="font-size: 32px;">this is paragraph</span></p>“”,“metafields”:[{“key”:“title”,“value”:“as”,“type”:“single_line_text_field”,“namespace”:“global”},{“key”:“description”,“value”:“as”,“type”:“single_line_text_field”,“namespac
e”:“global”}]}}

Request url : https://atikshakil.myshopify.com/admin/api/2022-04/blogs/88187142400/articles.json

Response : Bad Request

Hi,

Your post data is wrong, there are extra quotes in the body_html property(before and after). Also, just json stringify the body_html, it should work.

Try with this post data:

{
  "article": {
    "title": "Its easy to see why so many people love",
    "body_html": "## this is heading1\n

add space after that line

\n

 

\n

 

\n

this is paragraph

",
    "metafields": [
      {
        "key": "title",
        "value": "as",
        "type": "single_line_text_field",
        "namespace": "global"
      },
      {
        "key": "description",
        "value": "as",
        "type": "single_line_text_field",
        "namespace": "global"
      }
    ]
  }
}