Hey guys,
I'm new to AutoMagic and was wondering what is the most advised way to use send JSON Post request to an API? I'm using Toggl's API, more specifically the start and stop timer calls, but I can't seem to figure out how to go about it with AutoMagic. If I need send screenshots, let me know.
Thank you,
Ghost
Api use, JSON POST request
Moderator: Martin
Re: Api use, JSON POST request
Hi,
You can use action HTTP Request with request method POST and content type General Text to send the request. You will likely have to prepare the entire JSON data in an action Script in a variable (e.g. json_data) and then just reference the variable in the action HTTP Request in field data with {json_data}.
Regards,
Martin
You can use action HTTP Request with request method POST and content type General Text to send the request. You will likely have to prepare the entire JSON data in an action Script in a variable (e.g. json_data) and then just reference the variable in the action HTTP Request in field data with {json_data}.
Regards,
Martin
-
- Posts: 3
- Joined: 10 Nov 2017 20:03
Re: Api use, JSON POST request
Awesome, Thank you!
Re: Api use, JSON POST request
You can look more example of using http API request at here
viewtopic.php?f=6&t=6748
To create JSON data, you can create a map first, using newMapFromValues(). Then use toJSON() to convert the map to JSON, or simply just show the variable in jsonformat >> {data,jsonformat}
Look at this for example of creating and sending the JSON.
viewtopic.php?f=5&t=3088
viewtopic.php?f=6&t=6748
To create JSON data, you can create a map first, using newMapFromValues(). Then use toJSON() to convert the map to JSON, or simply just show the variable in jsonformat >> {data,jsonformat}
Look at this for example of creating and sending the JSON.
viewtopic.php?f=5&t=3088
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.