Skip to content

HTTP Requests HTTP Requests: JSON APIs

Summary

This module contains functions for sending HTTP requests & processing JSON responses.

It can be used to integrate PPA tasks with systems & applications that have JSON APIs.

Actions

http_requests.json.

delete

Make a DELETE request to a URL that returns a JSON response.

Minimum Plugin Version: 3.1.0

Input
  • url: the full url that you want to request

  • headers: an optional dictionary with the request headers

  • params: an optional dictionary with the query parameters

  • cookies: an optional dictionary with the request cookies

  • basic_auth: an optional BasicAuth dictionary

  • form_data: optional form data to send in the request

  • json_data: optional JSON data to send in the request

  • verify: set to false to skip certificate checking (defaults to true)

Output

A JsonResponse dictionary.

Request Data

You cannot supply values for both the form_data & json_data parameters to this action.

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

Make an HTTP DELETE request with some query parameters.

1
2
3
4
5
6
7
8
9
- http_requests.json.delete:
    url: https://httpbin.org/delete
    params:
      key1: value1
      key2: value2
  save: response

- ppa.ui.output_info:
    text: Response code was {{ response.status_code }}

http_requests.json.

get

Make a GET request to a URL that returns a JSON response.

Minimum Plugin Version: 1.0.0

Input
  • url: the full url that you want to request

  • headers: an optional dictionary with the request headers

  • params: an optional dictionary with the query parameters

  • cookies: an optional dictionary with the request cookies

  • basic_auth: an optional BasicAuth dictionary

  • verify: set to false to skip certificate checking (defaults to true)

Output

A JsonResponse dictionary.

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

Make an HTTP GET request using basic authentication.

1
2
3
4
5
6
7
8
9
- http_requests.json.get:
    url: https://httpbin.org/basic-auth/username/password
    basic_auth:
      username: username
      password: password
  save: response

- ppa.ui.output_info:
    text: Response code was {{ response.status_code }}

http_requests.json.

patch

Make a PATCH request to a URL that returns a JSON response.

Minimum Plugin Version: 3.1.0

Input
  • url: the full url that you want to request

  • headers: an optional dictionary with the request headers

  • params: an optional dictionary with the query parameters

  • cookies: an optional dictionary with the request cookies

  • basic_auth: an optional BasicAuth dictionary

  • form_data: optional form data to send in the request

  • json_data: optional JSON data to send in the request

  • verify: set to false to skip certificate checking (defaults to true)

Output

A JsonResponse dictionary.

Request Data

You cannot supply values for both the form_data & json_data parameters to this action.

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

Make an HTTP PATCH request with some query parameters.

1
2
3
4
5
6
7
8
9
- http_requests.json.patch:
    url: https://httpbin.org/patch
    params:
      key1: value1
      key2: value2
  save: response

- ppa.ui.output_info:
    text: Response code was {{ response.status_code }}

http_requests.json.

post

Make a POST request to a URL that returns a JSON response.

Minimum Plugin Version: 3.1.0

Input
  • url: the full url that you want to request

  • headers: an optional dictionary with the request headers

  • params: an optional dictionary with the query parameters

  • cookies: an optional dictionary with the request cookies

  • basic_auth: an optional BasicAuth dictionary

  • form_data: optional form data to send in the request

  • json_data: optional JSON data to send in the request

  • verify: set to false to skip certificate checking (defaults to true)

Output

A JsonResponse dictionary.

Request Data

You cannot supply values for both the form_data & json_data parameters to this action.

Supplying Credentials

You should always use a PPA Vault integration to provide credentials to a plugin action.

Example

Making an HTTP POST request to fill in a form.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
- http_requests.json.post:
    url: https://httpbin.org/post
    form_data:
      comments: ""
      custname: John Doe
      custemail: john.doe@fakemail.com
      custtel: "123456"
      delivery: "19:45"
      size: large
      topping:
        - bacon
        - cheese
  save: response

- ppa.ui.output_info:
    text: Response code was {{ response.status_code }}