How to use api via http request

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
Indiboy
Posts: 27
Joined: 12 Apr 2017 06:07

How to use api via http request

Post by Indiboy » 22 Jun 2017 19:53

I want to use API
Here is the documentation
https://dirtymarkup.com/docs


How do i use it via automagic premium?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: How to use api via http request

Post by Martin » 22 Jun 2017 20:14

Hi,

You can use an action HTTP Request:
URL: https://dirtymarkup.com/api/html
Request Method: POST
Content Type: application/x-www-form-urlencoded
Form Field List: code=<html>test,indent=2
Store response in variable

The response seems to be a JSON so you can extract the formatted text using an action Script:

Code: Select all

formatted_text=fromJSON(response)["clean"];
Please note that the form field list needs to be properly formatted in case the code contains commas and other special characters. You can prepare the form field list in a script by populating a variable list and then use {list,listformat,comma} to create the form field list. Example script:

Code: Select all

list = newList();
addElement(list, "code="+your_code);
addElement(list, "line-length=120");
Regards,
Martin

Post Reply