Http request through postman

Hello all
does somebody know how could i sent http request to ewelink through postman ?

I would like to command my connected switch sonoff with an http request.

it seems ewelink have an API but i didn’t hunderstand how to send it a request with postman…

1 Like

nobody ?

Please refer to:

thanks for your answer

so i upload
image
in postman and then tried to get region.
but i receive error:

can’t login too:

so some help would be appeciate

Was your Appid created on the eWeLink Developer Platform?

I don’t succed to register on this platform:
when i click on “get verification code” there is a popup “the account has been registred” but i don’t receive any email…
i tried with 2 different email adress without change !
what must i do ?

Just log in by your ewelink App account.

Oh yes ! i was trying to create an account !
thanks

OK finally i succed to obtain appid !
but now when i post region, I got:

{
    "error": 400,
    "msg": "sign verification failed",
    "data": {}
}

how can i obtain sign ?
I tried APP SECRET but with same result

nobody can help me ?

Have informed our colleague from open-API team, they will reach out to you.

I did some tests from Node-Red, http requests directly no a NS Panel Pro:

First, you need to get a Token. Send a GET command to:
http://192.168.0.155:8081/open-api/v1/rest/bridge/access_token
(use the IP address of your own system :slight_smile: )
In NodeRed, the http requests already have the option to choose if it is a GET, PUT, POST or DELETE request, I don’t remember right now how would it be done directly from a browser, for example…

You have to activate the sending Token in your hub before sending the command.
The token you receive has to be used in the subsequent commands.

Other commands look something like this:
http://192.168.0.155:8081/open-api/v1/rest/devices/

and the command has a Header like:
Content-Type application/json
Authorization Bearer e365x0e5-2cx2-47xb-8xd5-cabx407d5xb9

where the last number is the token you previously received. Again, I don’t know how to manage this Header part directly in a Browser, but it shouldn’t be difficult in a Program.

Other commands I tried:
http://192.168.0.155:8081/open-api/v1/rest/bridge (GET)

http://192.168.0.155:8081/open-api/v1/rest/devices/583c561e-9c8e-4933-8363-26bba3135694 (DELETE, the number is the virtual device number)

http://192.168.0.155:8081/open-api/v1/rest/devices/05f6b730-2334-4ff2-b9ae-7cd5c63efdaf:{“temperature”:{ temperature": 37 }}
(this was also for a virtual device)

I hope it helps

The APPID you obtain is applicable to Oauth2.0 interface, you need to obtain at through authorization, and then call the API interface; Specific api can refer to the documentation authorization.
https://ewelink.gitee.io/ewelink-api/#/en/OAuth2.0

ok so I’m moving forward a little:
in fact to get sign i needed to set app secret in environment variables.
now, when i post
https://apia.coolkit.cn/v2/utils/get-region?countryCode=+33
i get this response:

{
    "error": 407,
    "msg": "the path of request is not allowed with appid:ZhBJaZiC5cm...7m9jY3Mnlq",
    "data": {}
}

I checked Appid, it is the good one.
when i read doc i see:

406 and 407: Account error
This can have 2 causes:
The device is not allowed to be handled by this account.
The device belongs to another account.

In both cases you will need to contact eWeLink with the in-app feedback. Provide them the Device ID (if you can find it, mostly at the back of the device or on the box it came in) and your eWeLink account (if you are the owner of the device).

but i don’t understand the connection with device, because i not succed to login yet !
so i don’t know what to to now for further…
help would be appreciated

nobody can help me ?

This represents that your APPID does not have permission to access this API. Currently, applications created through the eWeLink developer center can only use OAuth2.0 related interfaces. There is a separate chapter on this on the open platform, and the available interfaces are also listed in the application details introduction.

Secondly, users who use the OAuth2.0 scheme to log in and authorize do not actually need to obtain information about their region based on the country/region code.

Example of authorization login code: https://github.com/nocmt/eWeLinkOAuthLoginDemo

Interface document link: https://coolkit-technologies.github.io/eWeLink-API/#/en/OAuth2.0

Example of calling Postman for OAuth2.0 interface: https://raw.githubusercontent.com/CoolKit-Technologies/eWeLink-API/main/media/files/CoolKit_OAuth2.0_Postman_Demo.zip

Screenshots of the interfaces available to you: