VivaPayments / API

Index of Viva Wallet open source projects on GitHub.
139 stars 163 forks source link

{"detail":[{"loc":["body"],"msg":"value is not a valid dict","type":"type_error.dict"}]} #2471

Closed leofabiani closed 9 months ago

leofabiani commented 9 months ago

I authenticate and receive token for POS device then i use bearer authentication to retraive online devices.

i get constantyl the error : {"detail":[{"loc":["body"],"msg":"value is not a valid dict","type":"type_error.dict"}]} even if the schema is as per your instructions. (see below the code)

$xml = json_decode($result); $token = $xml->access_token; //authencication token bearer //search pos $url2 = "https://api.vivapayments.com/ecr/v1/devices:search"; $curlSES2=curl_init($url2);

$fields='{"statusId":"1","sourceCode":"3395"}';

// "statusId":1 or "statusId":"1" ?? (anyway both doesnt work) - in the documentation in diffrent pages tere are different data //types. ??!!

//is the source code the id of the store?? nowhere is defined in the documetnation, what should be the lenght??

//step2

curl_setopt($curlSES2,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curlSES2,CURLOPT_POST,true);
curl_setopt($curlSES2,CURLOPT_POSTFIELDS ,$fields);
curl_setopt($curlSES2, CURLOPT_HTTPHEADER, [
    'Authorization: bearer '.$token,
    'Accept: application/json',
    'Content-Length: ' . strlen($fields)
]);
curl_setopt($curlSES2, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($curlSES2, CURLOPT_TIMEOUT,30);

//step3 $result=curl_exec($curlSES2); $my_array = json_decode($result, true); //step4 curl_close($curlSES2); if(isset($my_array['Message'])){

    $resultcurl =  $my_array['Message'];
    echo "error :".$resultcurl;
    //soething is wrong => here i get always the error that the body is not as per schema??!!
}else{
    echo $result;

}