cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Issue in creating Thing using RESTAPI

AS_1307
13-Aquamarine

Issue in creating Thing using RESTAPI

Hello Team,

 

Greeting of the day!

I'm trying to connect to the ThingWorx platform and make REST calls to call Services, update Properties, to make calls to REST API I m using POSTMAN. It's throwing me 400 error.

 

I', attaching all my details here.

 

http://localhost:8080/Thingworx/Resources/EntityServices/Services/CreateThing

Used the app key 

Accept: application/json

content type: application/json

 

{
    "name": "SomeTestThing",
    "thingTemplateName": "GenericThing"
}

 

Kindly help me to resolve this.

 

Thanks in advance.

 

AS

ACCEPTED SOLUTION

Accepted Solutions

To make it easier: Can you share your postman request? You need to add it to a postman collection. On the collection you can rightclick and export to a .json file. So we can import your request and see what is wrong.

View solution in original post

11 REPLIES 11

It all looks correct.

Just to double-check, you're setting appKey, Content-Type and Accept in the headers and the json is in the body, right?

Are you using a custom developed app to send the request or doing it via Postman or plain curl?

I'd suggest to try first with Postman if you haven't yet.

 

There are a few TS articles / cases, e.g. https://www.ptc.com/en/support/article/cs341975 (issue related to  .Net SDK version) and https://www.ptc.com/en/support/article/cs343724 (issue related to incorrectly set headers)

I'd also check the logs to see the full 400 error response - additional details there can help.

 

Also it can be just a matter of a typo - I've attached a screenshot (0012.png) with http 400 error and the cause is just an extra comma.

I've also attached the screenshots (0011.png and 0011a.png) with correct headers and body sections, just for reference.

There are extra fields in the json body - description and tags, they're optional, having name and thingTemplateName is enough.

AS_1307
13-Aquamarine
(To:DmitryTsarev)

Hello,

 

Thanks for the response. I'm using  POSTMAN to send request. I've tried as per your guidance and attaching the same, but still i'm facing 400 error.

 

Please have a look.

What's in the response body and what's the full status of the 400 error?

On the screenshot below I intentionally added extra comma to reproduce the 400 error to show where you can check it.

There also can be extra details in the `ApplicationLog.log` and `ErrorLog.log` in the `Thingworx Storage\logs` folder

 

DmitryTsarev_1-1673257077922.png

DmitryTsarev_2-1673257353751.png

 

AS_1307
13-Aquamarine
(To:DmitryTsarev)

I'm attaching error over here. I saw you shown me 400 error, but i checked in my body no extra comma nothing. 

nmilleson
17-Peridot
(To:AS_1307)

@AS_1307 ,

 

It looks like you have a mismatch between your port (8080) and your http protocol (https)...

 

If you're on port 8080, change your address to http:// instead of https://

 

-Nick

As Nick mentioned, this is due to port / protocol mismatch.

 

But this particular error doesn’t seem to be related to the original problem. And on the Snip3.png in your post above you’re correctly using http and port 8080

AS_1307
13-Aquamarine
(To:DmitryTsarev)

Yes, But still it same.

To make it easier: Can you share your postman request? You need to add it to a postman collection. On the collection you can rightclick and export to a .json file. So we can import your request and see what is wrong.

AS_1307
13-Aquamarine
(To:nmutter)

Hey, Thanks everyone for the help. The issue is resolved.

 

 

Thank you.

AS

Happy you got it working!

You marked my post as answer, but I did not provide any input regarding your issue. Can you write what the issue in the end was? Maybe you may also want to mark a different post as solution, which helped you find the issue. So the next person with the same issue has some ideas what may be wrong.

Thanks!

AS_1307
13-Aquamarine
(To:nmutter)

Hi, Sorry it happened by mistake, but the input and articles provided by @DmitryTsarev really worked out. Thank you all for the useful inputs provided by the team.

 

Thanks,

AS

Announcements


Top Tags