# Client side API

**URL:** <https://discourse.mozilla.org/t/client-side-api/67844>\
**Category:** WebThings\
**Created:** [September 20, 2020, 12:40pm UTC](https://discourse.mozilla.org/t/client-side-api/67844 "2020-09-20T12:40:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahsa.mohammadpourghaeni](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mahsa.mohammadpourghaeni](https://discourse.mozilla.org/u/mahsa.mohammadpourghaeni)\
**Post date:** [September 20, 2020, 12:40pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/1 "2020-09-20T12:40:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mrstegeman](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mrstegeman](https://discourse.mozilla.org/u/mrstegeman)\
**Post date:** [September 20, 2020, 5:14pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/2 "2020-09-20T17:14:55Z")

</div>

The API is documented here: [https://iot.mozilla.org/wot/](https://iot.mozilla.org/wot/)

---

<div class="post-metadata">

**Author:** ![mahsa.mohammadpourghaeni](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mahsa.mohammadpourghaeni](https://discourse.mozilla.org/u/mahsa.mohammadpourghaeni)\
**Post date:** [September 21, 2020, 5:09am UTC](https://discourse.mozilla.org/t/client-side-api/67844/3 "2020-09-21T05:09:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mrstegeman](https://avatars.discourse-cdn.com/v4/letter/m/a5b964/32.png) [@mrstegeman](https://discourse.mozilla.org/u/mrstegeman)\
**Post date:** [September 21, 2020, 4:57pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/4 "2020-09-21T16:57:21Z")

</div>

[This library](https://github.com/tim-hellhake/webthings-client) should serve as a good example of how to communicate with the gateway.

---

<div class="post-metadata">

**Author:** ![mahsa.mohammadpourghaeni](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mahsa.mohammadpourghaeni](https://discourse.mozilla.org/u/mahsa.mohammadpourghaeni)\
**Post date:** [September 27, 2020, 10:51am UTC](https://discourse.mozilla.org/t/client-side-api/67844/5 "2020-09-27T10:51:01Z")

</div>

hello again,  
sorry but I really don’t know how to make this url(“[http://mythingserver.com/things/pi/properties/led](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)  
{  
???  
}

---

<div class="post-metadata">

**Author:** ![marcgraham](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/marcgraham/32/36804_2.png) [@marcgraham](https://discourse.mozilla.org/u/marcgraham)\
**Post date:** [September 27, 2020, 1:58pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/6 "2020-09-27T13:58:11Z")

</div>

Hi,

When I need to figure stuff like this out I use the postman app – \> [Download Postman | Get Started for Free](https://www.postman.com/downloads/). Have you seen this?

I use the app to make the call →

 ![Screen Shot 2020-09-27 at 7.00.51 AM](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/1/1/1113edb1ce490a72a48aed5fac6351cf22f525ef.png)

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

 ![Screen Shot 2020-09-27 at 6.55.47 AM](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/2/e/2e79cdd247117c68cf8dab54894e7195d2281988.png)

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

---

<div class="post-metadata">

**Author:** ![mahsa.mohammadpourghaeni](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mahsa.mohammadpourghaeni](https://discourse.mozilla.org/u/mahsa.mohammadpourghaeni)\
**Post date:** [September 29, 2020, 4:43pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/7 "2020-09-29T16:43:13Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![marcgraham](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/marcgraham/32/36804_2.png) [@marcgraham](https://discourse.mozilla.org/u/marcgraham)\
**Post date:** [September 29, 2020, 7:10pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/8 "2020-09-29T19:10:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mahsa.mohammadpourghaeni](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@mahsa.mohammadpourghaeni](https://discourse.mozilla.org/u/mahsa.mohammadpourghaeni)\
**Post date:** [September 30, 2020, 10:35am UTC](https://discourse.mozilla.org/t/client-side-api/67844/9 "2020-09-30T10:35:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![marcgraham](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/marcgraham/32/36804_2.png) [@marcgraham](https://discourse.mozilla.org/u/marcgraham)\
**Post date:** [September 30, 2020, 2:38pm UTC](https://discourse.mozilla.org/t/client-side-api/67844/10 "2020-09-30T14:38:24Z")

</div>

Let me introduce you to stackoverflow:

> <https://stackoverflow.com/questions/3821784/whats-the-difference-between-n-and-r-n/3821814#3821814>

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.
