0
I’m starting an integration with B2W, they use a REST/JSON API, I am not finding where is wrong in my code, it is something related to the header, because I test with the Chrome dhc add-on and records the change correctly:
my code:
$url = 'https://api-sandbox.bonmarketplace.com.br/sku/10205_SKU1/price';
$data = json_encode(array(
"sellPrice"=> "400.00",
"listPrice"=> "400.00"
)
);
//echo "<br>".$usuario = base64_encode("$username:");
//Content-Type:application/json;charset=utf-8;
$options = array(
"http" => array(
"method" => "PUT",
"header" => "Content-Type: [application/json; charset=UTF-8; Authorization: Basic NjU5NjdGQkZBMDEzNjUwMTkyNzc1OTQ5MDI2NjUzNEU6",
"content" => $data
));
print_r($options);
$context = stream_context_create($options);
print_r($context);
// make the request
$response = file_get_contents($url, false, $context);
Error 401 Unauthorized
This json ai can be a common php array, when sending vc calls
json_enconde()
.– rray
Yes, I’ve even built it into array to use the function, but my question is on the structure of the code on how to call the API using post and pass this ARRAY
– luis ricardo
tried sending a hash with random md5 to see if the problem isn’t caching the process output?
– Ivan Ferrer
Hi Ivan, how would this implementation? Can you help me?
– luis ricardo