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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Issue in creating Thing using RESTAPI

AS_1307
12-Amethyst

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

1 ACCEPTED SOLUTION

Accepted Solutions
nmutter
14-Alexandrite
(To:AS_1307)

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.

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

 

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

Yes, But still it same.

nmutter
14-Alexandrite
(To:AS_1307)

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
12-Amethyst
(To:nmutter)

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

 

 

Thank you.

AS

nmutter
14-Alexandrite
(To:AS_1307)

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
12-Amethyst
(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

Top Tags