Adding more than one option to the product by the Shopify api

Asked

Viewed 34 times

0

I am doing the integration with Shopify, but I can not by any way found add more than one 'option' in the product using the API. The documentation of Shopify is very bad!

Unsuccessful example:

"options" => array(
    array(
       "name"=> "Cor",
       "position" => 1
    ),
    array(
       "name"=> "Tamanho",
       "position" => 2
    )
),

Returns the following header / error:

array(
'headers' => array(
    'status' => 'HTTP/1.1 422 Unprocessable Entity',
    'Server' => 'nginx',
    'Date' => 'Fri, 13 Apr 2018 20',
    'Content-Type' => 'application/json; charset=utf-8',
    'Transfer-Encoding' => 'chunked',
    'Connection' => 'keep-alive',
    'X-Sorting-Hat-PodId' => '56',
    'X-Sorting-Hat-PodId-Cached' => '0',
    'X-Sorting-Hat-ShopId' => '2120646713',
    'X-Sorting-Hat-Section' => 'pod',
    'X-Sorting-Hat-ShopId-Cached' => '0',
    'Referrer-Policy' => 'origin-when-cross-origin',
    'X-Frame-Options' => 'DENY',
    'X-ShopId' => '2120646713',
    'X-ShardId' => '56',
    'X-Stats-UserId' => '0',
    'X-Stats-ApiClientId' => '2344784',
    'X-Stats-ApiPermissionId' => '29651009593',
    'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' => '1/40',
    'X-Shopify-Shop-Api-Call-Limit' => '1/40',
    'Strict-Transport-Security' => 'max-age=7889238',
    'X-Request-Id' => '3ae5cd54-ffd5-4eaa-95de-f8884b14bd4f',
    'Content-Security-Policy' => 'default-src 'self' data',
    '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%2Fproducts&source%5Bsection%5D=admin_api&source%5Buuid%5D=3ae5cd54-ffd5-4eaa-95de-f8884b14bd4f',
    'X-Dc' => 'ash,cloud2',
    'Via' => '1.1 google',
    'Alt-Svc' => 'clear'
),
'response' => '{"errors":{"options":["is invalid"],"name":["can't be blank"]}}'
)

when sending so (below), an option is created and if I try to add another one in the same way using the PUT request, it overwrites the existing one, even if I inform a new position.

"options" => 
    array(
       "name"=> "Cor",
       "position" => 1
    ),

SOMEONE GOT ME A LIGHT?

  • Can make a POST instead of PUT?

  • PUT by default is used for updates.

  • I do the POST without problem, plus the POST can only add an option, and when I use the PUT to update the product, adding another option, it updates the existing, the tag 'position', serves to inform which option is, has a limit of 3.

  • On the link https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/options-error-when-creating-product-via-post-179779 the user @Ryanmarshall reported that the problem was in the way he was making the request.

  • Hello Valdeir, I appreciate your help, according to the link you sent me, I am doing exactly as indicated, using the json request... but finally the error remains!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.