Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
protogrid:api_endpoints [2017-12-08 16:45] – pgrid_wiki_admin | protogrid:api_endpoints [2021-12-14 04:03] – [/api/v2/apps/<app_name>/mailsend] dru | ||
---|---|---|---|
Line 7: | Line 7: | ||
==== Example successful response ==== | ==== Example successful response ==== | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | } | + | } |
} | } | ||
</ | </ | ||
==== Example failure response ==== | ==== Example failure response ==== | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | { … }, | + | { … }, |
- | { … } | + | { … } |
- | ], | + | ], |
- | " | + | " |
- | " | + | " |
} | } | ||
</ | </ | ||
- | ===== End Points | + | ===== Field Types ===== |
+ | In Protogrid there exist different types of fields such as numbers, text or dates. | ||
+ | |||
+ | ==== Number Field ==== | ||
+ | ==== Text Field ==== | ||
+ | ==== Date Time Field ==== | ||
+ | Protogrid always uses [[https:// | ||
+ | ==== Relation Field ==== | ||
+ | ==== Role Field ==== | ||
+ | |||
+ | ==== Rich Text Field ==== | ||
+ | |||
+ | ===== Endpoints | ||
The Protogrid JSON API offers the following API endpoints: | The Protogrid JSON API offers the following API endpoints: | ||
==== / | ==== / | ||
- | [GET] Returns a list of all applications | + | [GET] Returns a list of all Applications |
+ | |||
+ | Example request: | ||
+ | <code http> | ||
+ | https:// | ||
+ | </ | ||
- | Example request: <code http> https:// | ||
Example response: | Example response: | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | { | + | { |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | }, | + | }, |
- | { | + | { |
- | " | + | " |
- | " | + | " |
- | … | + | … |
- | }, | + | }, |
- | … | + | … |
- | ] | + | ] |
} | } | ||
</ | </ | ||
==== / | ==== / | ||
- | [GET] Returns basic information about one application. | + | [GET] Returns basic information about one Application. |
+ | |||
+ | Example request: | ||
+ | |||
+ | < | ||
+ | https:// | ||
+ | </ | ||
- | Example request: < | ||
Example response: | Example response: | ||
- | < | + | |
+ | < | ||
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | } | + | } |
} | } | ||
</ | </ | ||
==== / | ==== / | ||
- | [GET] Returns a list of all view names in this application. | + | [GET] Returns a list of all view names in this Application. |
- | Details on what views are supported, see [[protogrid: | + | Details on what views are supported, see [[protogrid: |
+ | |||
+ | Example request: | ||
+ | |||
+ | < | ||
+ | https:// | ||
+ | </ | ||
- | Example request: < | ||
Example response: | Example response: | ||
- | < | + | |
+ | < | ||
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | {" | + | {" |
- | {…} | + | {…} |
- | ] | + | ] |
- | } | + | } |
} | } | ||
</ | </ | ||
==== / | ==== / | ||
- | Most of the API endpoints | + | Most of the API endpoints except you to specify App or Card IDs. At the time at which this data is requested, these ids therefore already need to be known. It is therefore necessary to have convenient ways of asking Protogrid about what ids are available based on different search criteria. Database views can be used to acquire collections of data based on sorting and filtering URL parameters. |
[GET] Returns all the entries in the specified view. Please note that URL parameters must be URI encoded. | [GET] Returns all the entries in the specified view. Please note that URL parameters must be URI encoded. | ||
Line 111: | Line 139: | ||
* end_key: [" | * end_key: [" | ||
* keys: [" | * keys: [" | ||
- | * page_number: | + | * page_number: |
- | * limit: Accepts a number, which defines how many cards are returned | + | * limit: Accepts a number, which defines how many Cards are returned |
* Example: limit=15 | * Example: limit=15 | ||
* Default value: 10 | * Default value: 10 | ||
- | * descending: If set to true the results will be in descending order. | + | * descending: If set to true the results will be in descending order. If set to true start_key and end_key must be exchanged. |
* Example: descending=true | * Example: descending=true | ||
* Default value: False | * Default value: False | ||
Line 121: | Line 149: | ||
* Example: include_cards=true | * Example: include_cards=true | ||
* Default value: False | * Default value: False | ||
+ | * Please note that the “include_cards” parameter has a high cost in terms of performance. We therefore recommend using this functionality very economically, | ||
+ | |||
| | ||
- | Details: For more details about the URL parameters see the CouchDB documentation. | + | Please note: |
+ | * You may only use either " | ||
+ | * Key values must be cut off after 300 characters (e. g. string values and sortstrings) because these values are also cut off in the view index. | ||
+ | |||
+ | Details: For more details about the URL parameters see the [[http:// | ||
- | Full list of views can be found [[protogrid: | + | Full list of views can be found [[protogrid: |
Example request: | Example request: | ||
- | < | ||
- | The URL parameters need to be URI encoded. So from the example above the start_key parameter would look like < | + | < |
+ | https:// | ||
+ | </ | ||
+ | |||
+ | The URL parameters need to be URI encoded. So from the example above the start_key parameter would look like | ||
+ | < | ||
+ | start_key= %5B%22example_proto_key%22%2Cnull%5D | ||
+ | </ | ||
Example response: | Example response: | ||
- | < | + | |
+ | < | ||
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | {" | + | {" |
- | {…} | + | {…} |
- | ] | + | ] |
- | } | + | } |
} | } | ||
</ | </ | ||
Line 147: | Line 189: | ||
==== / | ==== / | ||
- | [POST] Creates a new card. It is necessary to specify a new card key (see [[create-button|here]] how to construct one) in the JSON under the field _id and a proto_key | + | [POST] Creates a new Card. It is necessary to specify a ' |
- | Example request: < | + | Example request: |
+ | < | ||
https:// | https:// | ||
</ | </ | ||
- | Together with the request | + | |
- | < | + | In the POST request |
- | {" | + | < |
+ | { | ||
" | " | ||
- | " | + | " |
- | {" | + | { |
- | {…} | + | |
+ | | ||
+ | | ||
+ | … | ||
] | ] | ||
} | } | ||
</ | </ | ||
+ | |||
Example response: | Example response: | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | "results": { | + | |
- | "_id: " | + | "result": { |
- | " | + | "_id": " |
- | " | + | " |
- | … | + | " |
- | } | + | " |
+ | | ||
+ | } | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Deprecated functionalities: | ||
+ | * Specification of a user-defined Card ID for a new Card: In previous versions, it was possible to freely specify the Card ID for a new Card in the ' | ||
==== / | ==== / | ||
- | [GET] Returns a specific | + | [GET] Returns a specific |
- | [DELETE] | + | [DELETE] |
- | [POST] Updates | + | [POST] Updates |
Example request: | Example request: | ||
- | < | + | < |
- | JSON: | + | https:// |
- | < | + | </ |
+ | |||
+ | In the POST request body, a JSON object needs to be sent as shown in the following example: | ||
+ | < | ||
{ | { | ||
- | _id: some_card_id, | + | |
- | proto_key: some_proto_key, | + | |
- | design_elements: | + | |
- | {" | + | { |
- | " | + | |
- | | + | |
+ | | ||
+ | … | ||
] | ] | ||
} | } | ||
</ | </ | ||
Example response: | Example response: | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | … | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== / | ||
+ | [GET] Returns the attachment identified by ' | ||
+ | |||
+ | [PUT] Uploads the Form Data attachment with name ' | ||
+ | |||
+ | Example GET request: | ||
< | < | ||
+ | https:// | ||
+ | </ | ||
+ | |||
+ | Example code for PUT request: | ||
+ | <code javascript> | ||
+ | var HOST = " | ||
+ | var APP_NAME = " | ||
+ | var CARD_KEY = " | ||
+ | |||
+ | function uploadFile(file, | ||
+ | function createFormData(file) { | ||
+ | var data = new FormData(); | ||
+ | data.append(" | ||
+ | data.append(" | ||
+ | return data; | ||
+ | } | ||
+ | |||
+ | var attachment_base_url = HOST + " | ||
+ | var initial_file_name = file.name; | ||
+ | var xhr = new XMLHttpRequest(); | ||
+ | xhr.open(" | ||
+ | xhr.upload.addEventListener(" | ||
+ | var progress = progress_event.loaded / progress_event.total * 66; // We want the progress bar to show " | ||
+ | progressCallback(progress); | ||
+ | }); | ||
+ | xhr.addEventListener(" | ||
+ | if (xhr.status == 200) { | ||
+ | var saved_filename = initial_file_name; | ||
+ | if (xhr.response && typeof(xhr.response) === ' | ||
+ | var response = JSON.parse(xhr.response); | ||
+ | if (response && typeof(response) === ' | ||
+ | saved_filename = response.result.file_name; | ||
+ | } | ||
+ | } | ||
+ | progressCallback(100); | ||
+ | successCallback({ | ||
+ | url: attachment_base_url + saved_filename | ||
+ | }); | ||
+ | } | ||
+ | }); | ||
+ | xhr.send(createFormData(file)); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | The corresponding Form Data: | ||
+ | < | ||
+ | ------WebKitFormBoundarya04hDppsnTo2uPOR | ||
+ | Content-Disposition: | ||
+ | |||
+ | image/png | ||
+ | ------WebKitFormBoundarya04hDppsnTo2uPOR | ||
+ | Content-Disposition: | ||
+ | Content-Type: | ||
+ | |||
+ | |||
+ | ------WebKitFormBoundarya04hDppsnTo2uPOR-- | ||
+ | </ | ||
+ | |||
+ | Example response after successful attachment upload: | ||
+ | <code javascript> | ||
{ | { | ||
- | " | + | |
- | "protogrid_environment_version": | + | "result": { |
- | " | + | "file_name": "Bildschirmfoto_2021-01-22_um_14.11.15.png" |
- | "_id: " | + | } |
- | " | + | |
- | " | + | |
- | … | + | |
- | } | + | |
} | } | ||
</ | </ | ||
Line 215: | Line 351: | ||
The following URL parameter can be used for paging: | The following URL parameter can be used for paging: | ||
- | * card_key: Passing a card_key will give you a result starting from that key | ||
* limit: Defines how many proto keys are returned. Takes a number between 1 and 1000, default is 10. | * limit: Defines how many proto keys are returned. Takes a number between 1 and 1000, default is 10. | ||
- | The returned result contains a key " | + | The returned result contains a key " |
+ | |||
+ | Example request: | ||
+ | < | ||
+ | https:// | ||
+ | </ | ||
- | Example request: < | ||
Example result: | Example result: | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | next_card_key: | + | " |
- | " | + | " |
- | {" | + | {" |
- | ] | + | ] |
- | } | + | } |
} | } | ||
</ | </ | ||
Line 237: | Line 376: | ||
[GET] Returns detailed information about the specified Proto. | [GET] Returns detailed information about the specified Proto. | ||
- | Example request: < | + | Example request: |
+ | < | ||
+ | https:// | ||
+ | </ | ||
Example result: | Example result: | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | { | + | { |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | … | + | … |
- | ], | + | ], |
- | " | + | " |
- | }, | + | }, |
- | {…}, | + | {…}, |
- | … | + | … |
- | ] | + | ] |
- | } | + | } |
} | } | ||
</ | </ | ||
==== / | ==== / | ||
- | [GET] Returns the keys for all cards based on the specified proto. | + | [GET] Returns the keys for all Cards based on the specified proto. |
The following URL parameter can be used for paging: | The following URL parameter can be used for paging: | ||
- | * card_key: Passing a card_key will give you a result starting from that key | ||
* limit: Defines how many card keys are returned. Takes a number between 1 and 1000, default is 10. | * limit: Defines how many card keys are returned. Takes a number between 1 and 1000, default is 10. | ||
- | The returned result contains a key “next_card_key” whose value is the next key not returned in this answer. | + | The returned result contains a key “next_card_key” whose value is the next key not returned in this answer. |
+ | |||
+ | Example request: | ||
+ | < | ||
+ | https:// | ||
+ | </ | ||
- | Example request: < | ||
Example result: | Example result: | ||
- | < | + | < |
{ | { | ||
- | " | + | |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | ], | + | ], |
- | " | + | " |
- | ] | + | ] |
} | } | ||
</ | </ | ||
+ | ==== / | ||
+ | [POST] Send an email | ||
+ | |||
+ | To be able to use this endpoint, the SMTP mail server of your organization must first be configured as the designated mail relay server in your Environment. If this has not been done yet, please contact [[protogrid-customer-support@ategra.ch|Protogrid Support]]. | ||
+ | |||
+ | Protogrid will fist try to establish a TLS session to the specified mail relay server and authenticate using the supplied credentials. If TLS is not available it will try to connect using SSL. Finally if SSL is not available the function tries to connect using unsecured SMTP protocol. | ||
+ | |||
+ | The mail will be sent according to the currently logged in user (mail address specified in user profile and the field "SMTP Server Password" | ||
+ | |||
+ | The following JSON data fields can be used: | ||
+ | * to: TO addresses (Array of Strings, mandatory) | ||
+ | * cc: CC addresses (Array of Strings) | ||
+ | * bcc: BCC addresses (Array of Strings) | ||
+ | * reply_to: ReplyTo addresses (Array of Strings) | ||
+ | * from: From address if other than logged in user (String) | ||
+ | * subject: Subject (String, mandatory) | ||
+ | * body_text_plain: | ||
+ | * body_text_html: | ||
+ | * inline_images: | ||
+ | * attachments: | ||
+ | |||
+ | Attachments and inline images must already reside inside Protogrid, each attached to a Card. The logged in user must have read access to this Card(s). Attachments and inline images are specified using an Object with the following structure: | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | By default, users can send a mail to up to 10 recipients. This limit can be increased via the roles assigned to the users using the field " | ||
+ | |||
+ | The returned result will include a success message or details about the particular error. | ||
+ | |||
+ | Example client-side jQuery request: | ||
+ | <code javascript> | ||
+ | $.post({ | ||
+ | url: " | ||
+ | data: JSON.stringify({ | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | {" | ||
+ | ], | ||
+ | " | ||
+ | {" | ||
+ | ] | ||
+ | }), | ||
+ | contentType: | ||
+ | }).done(function (response) { | ||
+ | alert(" | ||
+ | }); | ||
+ | </ | ||
+ | |||
+ | As a response you receive a JSON with the following structure: | ||
+ | * errors [Array]: Contains information if no single email could be sent, otherwise it is empty. | ||
+ | * messages [Array]: Contains information if Protogrid could not establish the connection to the mail server with the most secure transport encryption, otherwise it is empty. | ||
+ | * result [Object]: Contains information regarding individual recipients to whom the email could not be delivered. If the email could be delivered to all recipients equals to { " | ||
+ | |||
+ | Example response: | ||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | [ | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | [ | ||
+ | 554, | ||
+ | "5.7.1 < | ||
+ | ] | ||
+ | } | ||
+ | } | ||
+ | </ |