Article API - {"errors":{"article":"Required parameter missing or invalid"}}

kuldeepak
New Member
5 0 0

Article API - {"errors":{"article":"Required parameter missing or invalid"}}

 

How resolve this issue?

0 Likes
kuldeepak
New Member
5 0 0

Used these array when hit API

$tt = array(
"title"=> "My new Article title",
"author"=> "John Smith",
"tags"=> "This Post, Has Been Tagged",
"body_html"=> "<h1>I like articles</h1><p><strong>Yea</strong>, I like posting them through <span class='caps'>REST</span>.</p>",
"published_at"=> "Thu OCT 15 15:45:47 UTC 2020"
);

0 Likes
Greg_Kujawa
Shopify Partner
951 80 203

Assuming you are issuing a POST API request, I wonder if the published_at value isn't what's causing the issue. Can you future date this? I can't tell by just reading the API specs --> https://shopify.dev/docs/admin-api/rest/reference/online-store/article#create-2020-07. Maybe try leaving that property out and see if it works.

0 Likes
kuldeepak
New Member
5 0 0

Used without date and still get same error..

$tt = array(
"title"=> "My new Article title",
"author"=> "John Smith",
"tags"=> "This Post, Has Been Tagged",
"body_html"=> "<h1>I like articles</h1><p><strong>Yea</strong>, I like posting them through <span class='caps'>REST</span>.</p>"
);

0 Likes
Greg_Kujawa
Shopify Partner
951 80 203

Then I wonder what URL you are using? Below is a successful test request/response pair, where I referenced an existing, valid Blog ID. It came back just fine, based on the example in the API docs for the body.

POST https://{my_shop}.myshopify.com/admin/api/2020-07/blogs/3413441/articles.json HTTP/1.1
Content-Type: application/json
Authorization: Basic {my_auth}
User-Agent: PostmanRuntime/7.26.5
Accept: */*
Postman-Token: a049050b-c52b-4bea-b7a7-dd9a541761b7
Host: {my_shop}.myshopify.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 325

{
  "article": {
    "title": "My new Article title",
    "author": "John Smith",
    "tags": "This Post, Has Been Tagged",
    "body_html": "<h1>I like articles</h1>\n<p><strong>Yea</strong>, I like posting them through <span class=\"caps\">REST</span>.</p>",
    "published_at": "Thu Mar 24 15:45:47 UTC 2011"
  }
}
HTTP/1.1 201 Created
Date: Tue, 29 Sep 2020 17:03:38 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=db3c2520a5173d8b0cb391aaca2a702471601399018; expires=Thu, 29-Oct-20 17:03:38 GMT; path=/; domain=.myshopify.com; HttpOnly; SameSite=Lax
X-Sorting-Hat-PodId: 161
X-Sorting-Hat-ShopId: 3036253
Referrer-Policy: origin-when-cross-origin
X-Frame-Options: DENY
X-ShopId: 3036253
X-ShardId: 161
X-Stats-UserId: 
X-Stats-ApiClientId: 309925
X-Stats-ApiPermissionId: 8304915
X-Shopify-API-Terms: By accessing or using the Shopify API you agree to the Shopify API License and Terms of Use at https://www.shopify.com/legal/api-terms
HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT: 1/40
X-Shopify-Shop-Api-Call-Limit: 1/40
X-Shopify-API-Version: 2020-07
Location: https://{my_shop}.myshopify.com/admin/blogs/3413441/articles/392620933282
Strict-Transport-Security: max-age=7889238
X-Shopify-Stage: production
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.us.shopifycs.com https://js-agent.newrelic.com https://bam.nr-data.net https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Farticles&source%5Bsection%5D=admin_api&source%5Buuid%5D=677e5779-57df-4390-8380-1732b7e5dcde
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=create&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Farticles&source%5Bsection%5D=admin_api&source%5Buuid%5D=677e5779-57df-4390-8380-1732b7e5dcde
X-Dc: gcp-us-central1,gcp-us-east1,gcp-us-east1
NEL: {"report_to":"network-errors","max_age":2592000,"failure_fraction":0.01,"success_fraction":0.0001}
Report-To: {"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}
X-Request-ID: 677e5779-57df-4390-8380-1732b7e5dcde
NEL: {"report_to":"network-errors","max_age":2592000,"failure_fraction":0.01,"success_fraction":0.0001}
Report-To: {"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifycloud.com/v1/reports/nel/20190325/shopify"}]}
CF-Cache-Status: DYNAMIC
cf-request-id: 057c6aebe9000003cc9b168200000001
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 5da74759796103cc-ORD
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
Content-Length: 630

{"article":{"id":392620933282,"title":"My new Article title","created_at":"2020-09-29T17:03:38Z","body_html":"\u003ch1\u003eI like articles\u003c\/h1\u003e\n\u003cp\u003e\u003cstrong\u003eYea\u003c\/strong\u003e, I like posting them through \u003cspan class=\"caps\"\u003eREST\u003c\/span\u003e.\u003c\/p\u003e","blog_id":3413441,"author":"John Smith","user_id":null,"published_at":"2011-03-24T15:45:47Z","updated_at":"2020-09-29T17:03:38Z","summary_html":null,"template_suffix":null,"handle":"my-new-article-title-1","tags":"Has Been Tagged, This Post","admin_graphql_api_id":"gid:\/\/shopify\/OnlineStoreArticle\/392620933282"}}
0 Likes
kuldeepak
New Member
5 0 0

I have checked API directly and it fetch the data but not add data.

https://facevalue-dev.myshopify.com/admin/api/2020-07/blogs/72022229152/articles.json

My code here

$tt = array(
"title"=> "My new Article title",
"author"=> "John Smith",
"tags"=> "This Post, Has Been Tagged",
"body_html"=> "<h1>I like articles</h1><p><strong>Yea</strong>, I like posting them through <span class='caps'>REST</span>.</p>",
"published_at"=> "Thu JUN 11 15:45:47 UTC 2020"
);
$uu = $shopifyClint->call('POST', '/admin'.Yii::$app->params['API_DATE'].'blogs/'.$blog_id.'/articles.json', $tt);
print_r($uu);
 
Please check
0 Likes
Greg_Kujawa
Shopify Partner
951 80 203

Have you checked your access scope permissions to see if the API "user" has been authorized to create new articles?

 

https://shopify.dev/docs/admin-api/rest/reference/access/accessscope#index-2020-07

 

0 Likes