Skip to main content
1-Visitor
Dec 21, 2020 12:29 PM UTC
Solved

Creating thing hierarchy in Network using Postman

Hi All, 

 

I am using Postman (calling RESt API) to create things and network. I was successful in doing so. Now I am trying to build the hierarchy in the network for the things that are created.

I have used API key for authentication, and in the body tab I am using POST and providing the below URL where TestNetwork is my network  -

http://XXX.XXX.XXX.XXX:8080/Thingworx/Networks/TestNetwork/Services/AddConnection

 

I have selected "raw" in the radio button type as JSON 

I have used the below code -

 

{ "from" : "SomeTestThing", "to" : "SomeTestThing1" , "connectionType" : "Contains" }

 

But I got error 500 - internal server error 

 

I also tried with Javascript

var params = {

            from: "SomeTestThing" ,

            to: "SomeTestThing1" ,

            connectionType: "Contains" 

    };

 

        Networks["TestNetwork"].AddConnection(params);

 

got an error 403. 

 

Can you please help me where am I going wrong? I am suspecting the URL but don't know what's the correct way. 

 

Thanks In Advance

Swaraj

 

 

 

5-Regular Member
Dec 21, 2020 6:17 PM UTC

Hello @SO_9699370,


If you want to build the hierarchy in the network for the things that are created in ThingWorx you can do that with Postman. You can use Javascript in Postman, you can try the following example:

 

NetworkThingsConnection.jpg

 

 

Hope it helps,

 

4 replies

5-Regular Member
Dec 21, 2020 4:50 PM UTC

Hello @SO_9699370 ,

 

Have you tried with the URL in the following format:

 

http://XXX.XXX.XXX.XXX:8080/Thingworx/Things/TestNetwork/Services/AddConnection

 

Hope it helps,

Translate
17-Peridot
Dec 21, 2020 4:50 PM UTC

Your Postman request looks OK, given that there are no typos somewhere in your postman params http://localhost:8080/Thingworx/Networks/Net2/Services/AddConnection

At least, it works as expected on my side, I even copy&pasted the code from your message.

 

Very unlikely, but just in case, check the headers

Unbenannt2.JPG

 

Other than that... 500 is pretty generic error. What's there in the Application.log?

And, btw, which Thingworx version are you on?

Translate
5-Regular Member
Dec 21, 2020 6:17 PM UTC

Hello @SO_9699370,


If you want to build the hierarchy in the network for the things that are created in ThingWorx you can do that with Postman. You can use Javascript in Postman, you can try the following example:

 

NetworkThingsConnection.jpg

 

 

Hope it helps,

 

Translate
1-Visitor
Dec 22, 2020 11:25 AM UTC

Thank you all. 

 

I truthfully have no idea why it didn't work. I tried with the same URL and same JSON structure, it worked. Anyways thanks for all your input. I am closing this case but accepting the last comment as solution. 

 

Kind Regards

Swaraj 

Translate