Can not add device using [POST] api/devices via curl and php

Good day everyone.

would like to ask on the proper syntax used in API Post?
i am trying to create a device using [POST] api/devices in php curl.
the result i’m getting is ```
“message”: “invalid length: expected length 32 for simple format, found 0”,

This is the format of my post request:
$header = array();
$header[] = 'accept: application/json';
$header[] = 'Grpc-Metadata-Authorization: Bearer '.$jwt;
$header[] = "Content-Type: application/json";
$tags = array("additionalProp1"=>"","additionalProp2"=>"","additionalProp3"=>"");	
$vars = array("additionalProp1"=>"","additionalProp2"=>"","additionalProp3"=>"");
$field = array("applicationID"=>"$appid","description"=>"$desc","devEui"=>"$deveui",
$dev = array("device"=>$field);

$url = $ns."api/devices";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dev));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Shouldn’t that be applicationId?

1 Like

That solved it!

Thank you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.