Page 1 of 1

Api use, JSON POST request

Posted: 12 Nov 2017 06:34
by GhostTheToast
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

Re: Api use, JSON POST request

Posted: 12 Nov 2017 19:59
by Martin
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

Re: Api use, JSON POST request

Posted: 13 Nov 2017 00:27
by GhostTheToast
Awesome, Thank you!

Re: Api use, JSON POST request

Posted: 13 Nov 2017 08:10
by Desmanto
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