Put method

could any one send me an example of put method for mozilla things in postman please?
my url is like this: ip of web thing/things/a fix phrase for all things/properties/on2
i added authorization header because web things need bearer token.
I wrote this in the body: {“on2”: true}
but it returns 400 error and says not found.
but my url is exists for get method but not for put.
could you give me an example to see all headers,token,body,… is needed in postman inorder to set a property?

please help,
I want to directly write put request on properties of my web things.
the url of my web thing is correct because when I write Get requset on that url,it returnes correct json to me.
for example it returns: on:false
but I want to write put requset to change false to true.
but it returns 404 error!
how can I directly write put request for things without the need of web server( mozilla gateway)?
how should the url and headers be ?
(actually I’m designing gateway my self.I just want to put my gateway instead of mozilla gateway.so I need to know how to call web things to send them PUT requsets)
with model of address below i can call my thing with Get request and it’s response is true.but for sending PUT request this URL doesn’t work.

192.168.xx.xxx : this is the ip of my web thing and with Get requset it returns json to me and is ok.I have problem with PUT.
I’m testing these with postman.

nobody wants to answer me??
if my question isn’t clear tell me to ask it in different way
I’m really stuck with this :pensive:
i asked my question in 4 different topics,but i get no answer

If I understand your question correctly , I think you want to know how a PUT request works for a webthing. Before everything, your webthing should supports PUT request first if not it will return error. Here is a simple example of using an LED to turn it on and off using PUT request, if you have a raspberry pi you can connect an LED to GPIO port and run this simple node js program and try in postman

some references for you to

Below video can help you to understand how PUT is used to turn on/off and control brightness of smart bulb

1 Like

When you say, your devices are wifi based and are connected to internet…can you share more details of your device like brand and model ??? or is it a custom device developed using arduino/raspberry pi ? does your device have API available ?

it is a custom device developed using nodemcu with arduino code and yes it has api available because we difined our webthing exactly with arduino codes mentioned in webthings framework and from mozilla gateway it returns true response but when I want to send put request to it directly (to its ip address/deviceid/things/properties/propertyid)it returns 404 error!

why webthings don’t allow to have direct access(for PUT request) to them without an interface(mozilla gateway)??? :sob:

It is allowed. It appears that your URL is probably wrong. It should be:

thank you,but exactly I write this model of URL. with postamn I get 404 error and with running an html file including the code,I get cors error! it seems I don’t have access to my webthings for sending PUT request!
what’s the problem? Is it from headers I use?? :pensive:

If your tests are failing due to CORS errors you may be able to disable cors restrictions by including this header when your HTML loads: Access-Control-Allow-Origin: *

When the web page loads cors will allow content from any domain, not just same site.

Postman also has a way to include headers too I think.

In one of my old projects I wrote an Ajax method that sent browser 3rd-party data requests back to an origin server program that executed and returned put/get requests to remote servers… Lot’s of round trips but it worked great.

Maybe you should post your webthing code

This works for me in postman. I am using raspberry and Wemos D1-R2. As pointed out, I am using the IP assigned to Arduino for direct access. In this case I only have the webthings server running on Arduino and do not necessarily need the WebThings gateway running. Here is the code for Arduino