HTTP request from posman to macrodroid (FusionSolar)

jmlat

Member
Hello all
I try to do HTTP request to FusionSolar API
their tuto explains how to do this throught "postman"

i succed it after some hours...

but now i'd like do it with macrodroid. so i used HTTP request, but no way, it doesn't log in..


i'm newbee in API requests so i can't see where is the problem.

you will find screenshot of postman :
2023_11_07_15_45_38_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_46_10_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_46_26_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_46_46_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_47_20_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_47_40_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png2023_11_07_15_48_08_https_eu5.fusionsolar.huawei.com_thirdData_login_My_Workspace.png

and macrodroid.

1699368818241.jpg1699368818252.jpg1699368818272.jpg
i also tried to put username and systemcode in parameters page as basic autentification but it doesn't works either...

where do i mistake ?
 

RSF

Well-known member
First, make sure to configure your HTTP Request action to return the HTTP response (text) and HTTP response code (integer). Those values will halp you figure out how the server responded to your request.
Create the variables first...
1699410840564.png
Then specify them on the HTTP Request action (they're on the bottom of the first "tab"):
1699410945724.png


Second: Looking quickly at your parameters, I recommend deleting all the header parameters other than Connection and Cookie. The other parameters appear to be Postman-specific settings.
 

jmlat

Member
Thank you RSF.
i have already those variables:
code resonse 400
response:
<html>
<head><title>400bad
Request</title></head>
<body>
<center><h1>400bad
Request</h1></center>
<hr><center>product only</center>
</body>
</html>


but i don't know what to do with this...

and i I delete headers i have a code response 200 and no response...
 

RSF

Well-known member
A response code of 200 indicates "success", so that's progress.

If there's nothing in the http_response variable, that sounds like the action might be set up wrong. Please double-check that the variable you're using for the full response (not just the code) is a string type variable, and that the HTTP Request action is correctly configured to store the HTTP result into that variable. The response is supposed to look something like
{
"buildCode": "2",
"data": null,
"failCode": 0
etc. etc.

Unfortunately, according to that FusionSolar documentation page you provided in your original post, the FusionSolar API returns the authorization token in a cookie, vs. sending it in the HTTP response body. MacroDroid cannot currently read cookies sent in an HTTP response header. You could use a plug-in like the "HTTP Shortcuts" plug-in to get it. See this forum post where another user was able to get a cookie value using that plug-in.
 

jmlat

Member
but there is something in response !
response:
<html>
<head><title>400bad
Request</title></head>
<body>
<center><h1>400bad
Request</h1></center>
<hr><center>product only</center>
</body>
</html>
 
Top