Client side API

Hello,
I’m writing your program on Windows, that is, I wrote a web server on Windows, and now I need your client-side api so I can send my commands to things.
How can I access your api or have it’s code?

The API is documented here: https://iot.mozilla.org/wot/

1 Like

thanks,
could you please explain more how should I use the document to write the API?
can I see your sample code?

This library should serve as a good example of how to communicate with the gateway.

1 Like

hello again,
sorry but I really don’t know how to make this url(“http://mythingserver.com/things/pi/properties/led”)usable to return response to me like this:“led”: true.
actually I’m writing client side api for my web server and want to write put method to turn the led to off.so First I need to make the url above to have access to that,but I don’t know what should I write to communicate with things and get their response by that url.

actually what should I write to make my web server url recognizable for things?
I’m writing on .net core platform with c# language
I need your .sln file to see the api code.

// GET: things/@x/properties/@y
[HttpGet]
public IEnumerable Get()
{
???
return ???;}

[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
???
}

Hi,

When I need to figure stuff like this out I use the postman app – > https://www.postman.com/downloads/. Have you seen this?

I use the app to make the call -->

Then I can select the ‘Code’ entry (below the save button) and get an example for coding up the call.

It really helps me when I need to figure out stuff like this.

1 Like

thank you very much.it was very helpful.
just one question,I wrote everything exactly like you but a part of my out put was like this :
request.AddParameter(“application/json”, “{\r\n “on2” : true\r\n}”, ParameterType.RequestBody);
I dont know what should I do with \r !

Hi,

Take the newlines out of the data – {“alarm” : “true”} and you won’t get those.

I usually strip them out when I convert the json back to an object. Python and javascript have many methods of removing them. I imagine .net core does too.

hi,
I meant the generate code snippets tab in postman shows \r to me.
but in your example you just had \n. although you put Curly Brackets in the different lines , your c# code snippet out put doesn’t have \r.
can I see your headers in a photo or if it’s possible see the whole process you’ve done in order to run correct put method as a video or photo?
my url is true , i checked it with get method but my put method doesn’t work.every thing is like the photo you sent.just i think my headers are different or some thing is wrong with my token.

Let me introduce you to stackoverflow:

You need to adjust the call to your own needs. If you do not have security enabled you won’t need to send a token.

1 Like