1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

Rest APIs

Build a GET, DELETE, POST, PUT, or PATCH request with JSON data.

  1. GET
  2. DELETE
  3. POST
  4. PUT
  5. PATCH

Examples

Get

  var myHeaders = new Headers();
  myHeaders.append("Accept", "application/json; version=3");
  myHeaders.append("Authorization", "Token [TOKEN VALUE]");
  
  var requestOptions = {
    method: 'GET',
    headers: myHeaders,
    redirect: 'follow'
  };
  
  fetch("https://api.azionapi.net/digital_certificates/", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

Delete

  fetch('https://example.com/delete-item/' + id, {
   method: 'DELETE',
  })
  .then(res => res.text()) // or res.json()
  .then(res => console.log(res))

Post

  function createNewProfile(profile) {
      const formData = new FormData();
      formData.append('first_name', profile.firstName);
      formData.append('last_name', profile.lastName);
      formData.append('email', profile.email);
      return fetch('http://example.com/api/v1/registration', {
          method: 'POST',
          body: formData
      }).then(response => response.json())
  }
  createNewProfile(profile)
     .then((json) => {
         // handle success
      })
     .catch(error => error);

Put

  const putMethod = {
   method: 'PUT', // Method itself
   headers: {
    'Content-type': 'application/json; charset=UTF-8' // Indicates the content 
   },
   body: JSON.stringify(someData) // We send data in JSON format
  }
  // make the HTTP put request using fetch api
  fetch(url, putMethod)
  .then(response => response.json())
  .then(data => console.log(data)) // Manipulate the data retrieved back, if we want to do something with it
  .catch(err => console.log(err)) // Do something with the error

Patch

  const API_URL = 'https://api.azion.net/'                                           
  const API_PATH = 'api/v3/'
  fetch(API_URL + API_PATH + 'tasks', {
   headers: {
     'Accept': 'application/json',
     'Content-Type': 'application/json'
   },
   method: 'patch',                                                             
   body: JSON.stringify( { task: task } )                                       
  })

Didn’t find what you were looking for? Open a support ticket.