0

I'm trying to use the /product endpoint but keep getting

`400 Bad Request` response:
{"message":"\"%fieldName\" is required. Enter and try again.","parameters":{"fieldName":"product"}}

My header includes the Json content-type. I'm really lost on how to form the body. Or does this even go in body? Below is my request:

<?php
require_once ('connparams.php');
$headers = [
    "Authorization" => "Bearer " . $token,        
    "Content-Type" => "application/json"
];
$response = $client->request('post', 'products', 
["headers" => $headers],
["body" => 
["product" => 
        ["sku" => 12211]
]]
);

1 Answer 1

0

Try

$response = $client->request('post', 'products',
    $headers,
    [
        "product" => [
            "sku" => 12211
        ]
    ]
);

where $headers is an associative array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.