Adding more than one option to the product by api shopify

0

I'm doing integration with Shopify, but I can not by any way find myself adding more than one 'option' to the product using the API. The shopify documentation 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 I send so (below), an 'option' is created and if I try to add another one in the same way using the PUT request, it overrides the existing one even though I am reporting a new position.

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

SOMEONE CAN GIVE ME A LIGHT?

    
asked by anonymous 13.04.2018 / 22:59

0 answers