HTTP_shortcuts to Macrodroid

jmlat

Member
I used a request on HTTP shortcuts, but when I fire it with Macrodroid, it doesn't really works when it fire with timer (even if it works well when i try it manually) .

so I tried to sent my request directly with Macroidroid. but then i have fail code 305 ...

I checked all data in my request but i can't find the problem.
you will find here sccreenshots, maybe someone could help me...
 

Attachments

  • 1700478133345.jpg
    1700478133345.jpg
    187.1 KB · Views: 22
  • 1700478133361.jpg
    1700478133361.jpg
    157.6 KB · Views: 22
  • 1700478133380.jpg
    1700478133380.jpg
    197 KB · Views: 22
  • 1700478133393.jpg
    1700478133393.jpg
    132.9 KB · Views: 22
  • 1700478133400.jpg
    1700478133400.jpg
    105.7 KB · Views: 22
  • 1700478133411.jpg
    1700478133411.jpg
    184.6 KB · Views: 22

Dimlos

Well-known member
I'd like to help, but I can't seem to even try without credentials or an actual solar system.
The 305 status code must be accessed through a proxy server, so guess misconfigured.
 

jmlat

Member
I'd like to help, but I can't seem to even try without credentials or an actual solar system.
The 305 status code must be accessed through a proxy server, so guess misconfigured.
yes indeed to make this request requires a first identification request and to retrieve the information returned in a cookie (hence the use of "HTTP shortcuts" since apparently Macrodroid does not know how to retrieve cookies)....
on the other hand this 2nd request does not return a cookie which is why I tried to do it directly with Macrodroid...but without success
 

RSF

Well-known member
it works well when i try it manually
By "manually", do you mean that you execute the MacroDroid macro using the Test Actions command within MacroDroid? If not, how are you testing it manually?

fail code 305
Within your macro, if you inspect the value of your XSRF-TOKEN local variable, does it look right?
How does the macro set that local variable?

Are the 4th, 5th, and 6th screenshots from the HTTP Shortcuts plugin, or from Postman?
 

jmlat

Member
By "manually", do you mean that you execute the MacroDroid macro using the Test Actions command within MacroDroid? If not, how are you testing it manually?
Yes i use Test actions. Actually the problem when it fire is delay, sometime request need lot of time and Macrodroid don't really know when request from HTTP shortcuts is finished...i can use larges waiting, but then macro is quite long...
Within your macro, if you inspect the value of your XSRF-TOKEN local variable, does it look right?
Yes XSRF-TOKEN looks rigth
How does the macro set that local variable?
i succed in HTTP shotcuts to copy XSRF-TOKEN into clipboard so i can paste it in a Macrodroid variable
Are the 4th, 5th, and 6th screenshots from the HTTP Shortcuts plugin, or from Postman?
Yes that' right it was to qhow difference of request between HTTP shortcuts and Macrodoid....
 

RSF

Well-known member
Actually the problem when it fire is delay, sometime request need lot of time and Macrodroid don't really know when request from HTTP shortcuts is finished...i can use larges waiting, but then macro is quite long...

Do you have the Block next actions until complete option selected in your macro's HTTP Shortcuts action?
Screenshot 2023-11-27 9.15.56 AM.png

That should make MacroDroid wait for the request from HTTP Shortcuts to complete before continuing with the other actions in your macro.
 

jmlat

Member
Do you have the Block next actions until complete option selected in your macro's HTTP Shortcuts action?
View attachment 7697

That should make MacroDroid wait for the request from HTTP Shortcuts to complete before continuing with the other actions in your macro.
where did you find this ?
HTTP shortcuts is an android app separate from Macrodroid, so I start request with "lanch shortcut" and then i have not "block next action".
that's why i would request directly from Macrodroid but i didn't succed...
 

RSF

Well-known member
HTTP Shortcuts is capable of being a "plug-in" to applications like MacroDroid or Tasker -- as well as being a standalone Android application. Once you've installed HTTP Shortcuts, it should automatically appear as a plug-in in MacroDroid.

To execute it from MacroDroid,
  1. Use the Tasker/Locale Plugin action.
    Screenshot 2023-11-27 10.14.49 AM.png
  2. You should then see HTTP Shortcuts as an option for the plug-in:
    1701109225111.png
  3. Click on that, and it'll show a sub-option to execute a shortcut:
    1701109279945.png
  4. Click on that sub-option, and you should see a list of your pre-defined HTTP Shortcuts; click on the one you want to execute;
    1701109343881.png
  5. At that point, you should see the "Block next actions until complete" option
I don't know whether using this method to execute HTTP Shortcuts will require you to change how you get the XSRF token into MacroDroid -- hopefully not.
 

jmlat

Member
great ! i didn't know this possibility ! thanks RSF !
before testing the XSRF i tested on a second shortcut. it is fire and it finish (it show a popup when finished), but I don't succed to have response back...MD doesn't stop waiting ...
even if in the shortcut i defined in scripting which is execute if succes :"setResult("test")"..
how do you obtain response in MD ?
 

RSF

Well-known member
Create a local variable to receive the setResult() value, and have MacroDroid set it as part of the HTTP Shortcut action setup:

Screenshot 2023-11-27 5.52.42 PM.png

You could use your "XSRF_TOKEN" local variable instead of the "result" variable I used above...
 

jmlat

Member
Create a local variable to receive the setResult() value, and have MacroDroid set it as part of the HTTP Shortcut action setup:
I think it is what i did !
here are screenshots from macrodroid...
1701165584053.jpg

and from HTTP shortcuts:
1701165584057.jpg
I show "batterie ok"
but nothing in "reponseetxt"
and MD still waiting...
what did i mistake ?
 

Dimlos

Well-known member
If you set Response Handling to Show nothing, you can use a local variable.
I'm not that familiar with it, but doesn't setResurut("responsetxt") just assign the string "responsetxt" to a local variable?
By setResurut(response.body), the response of the HTTP request should be assigned.
 

Attachments

  • Response Handling.jpg
    Response Handling.jpg
    244.9 KB · Views: 5
  • Scripting.jpg
    Scripting.jpg
    181.7 KB · Views: 5
  • Like
Reactions: Vix

jmlat

Member
Make sure you have Global variable for setResult and Macrodroid enable
effectively, my variable was local in MD. so i tried with a global MD variable called "myGlobalMDVariable".
then MD doesn't still waiting again, Macro continue,
It's a succes !
but i can't receive result in my MD variable.
I tried to use setVariable("myGlobalMDVariable","testTextResponse") too in execute if succes in HTTP shortcuts, but i don't have nothing in MD "myGlobalMDVariable" variable.

If you set Response Handling to Show nothing, you can use a local variable.
yes i show nothing
I'm not that familiar with it, but doesn't setResurut("responsetxt") just assign the string "responsetxt" to a local variable?
By setResurut(response.body), the response of the HTTP request should be assigned.
Of course, you are rigth but my problem is that i don't receive any response in MD...
I thougth that using setResult("text") text was the name of the variable in which response is sent.
so I tried with setResult(response.body) but no more succes in MD variable


I tried to set manually some text in "myGlobalMDVariable". after macro execution, this variable become empty...so it is used but i don't succed to put a response in it !!!
 

Dimlos

Well-known member
Try a simpler test request with HTTP Shortcuts to see if the variable is assigned.
 

Attachments

  • httpbin.jpg
    httpbin.jpg
    115 KB · Views: 4
  • postman-echo.jpg
    postman-echo.jpg
    120.5 KB · Views: 4

Dimlos

Well-known member
I am able to assign the above response to a local variable in MacroDroid, so if this is not possible, then something is wrong with your setup.
 

Dimlos

Well-known member
Macros should be imported into MacroDroid and shortcuts should be imported into HTTP Shortcuts and tested.

MacroDroid must be v5.38.x to import macros.
Before executing, edit the action, select postman-echo_get and press OK.
 

Attachments

  • Macro.jpg
    Macro.jpg
    387.1 KB · Views: 3
  • http_request.macro
    4.6 KB · Views: 2
  • shortcuts.zip
    495 bytes · Views: 3
Last edited:

jmlat

Member
Macros should be imported into MacroDroid and shortcuts should be imported into HTTP Shortcuts and tested.

MacroDroid must be v5.38.x to import macros.
Before executing, edit the action, select postman-echo_get and press OK.
ok. i got a response...now i will have a look very fine in your request and your macro to understand where is my problem...
 

jmlat

Member
no i don't succed...
you will find the macro and shortcut i use...
the only difference i detected is your request is GET and mine is POST may be it does'nt works for POST.....

can you try with my files ?
and tell me if you can make it works ?
you should obtein a failcode 305 in message wich appears in popup...it's normal because you are not log..
but error and response still empty !
 

Attachments

  • http_request.macro
    12.5 KB · Views: 5
  • shortcut.zip
    1.4 KB · Views: 5
Top