Hello, I’m new to this world of IoT and I’m learning now.
During my lab, I’d need to create managed objects through Postman using the below JSON as per the document but I’m getting the error as “{“error”:“Failed to parse JSON string”}”
{
“c8y_IsDevice”: {},
“c8y_Position”: {
“lat”: “-33.97059”,
“lng”: “151.11619”
},
“name”: “Microservice tracker”
}
Actually I’m trying to deploy java based web service as per the steps outlined in the below link… could some help me to identify the issues? but I’m able to create simple managed objects without any issues,
https://cumulocity.com/guides/microservice-sdk/http/#microservice-java
Regards
Nirmal
Hey,
Welcome to the forum!
The JSON looks right if I compare with the example I have in my Postman. Is Postman returning the error or is it the server that is returning the error? If so, which code is the server returning? If succesful, you should get at 201 response.
Did you enter the JSON in the Body field as ‘raw’?
In Postman, under the Send and Save buttons, there’s a link named Code. Do that and export as curl. This is what my generated curl code looks like. Go compare and see if there’s any differences. That might give us a first indication.
curl --location --request POST 'https://XXXXXXX.us.cumulocity.com/inventory/managedObjects' \
--header 'Authorization: Basic changingthisforobviousreassons' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
"name": "testMeasurementDevice",
"c8y_IsDevice": {},
"c8y_SupportedMeasurements": [
"c8y_TemperatureMeasurement"]
}'
Its working now … Thanks @Mike_Reys