Difference between revisions of "API Create Template"

From IVS Wiki
Jump to: navigation, search
(Created page with "This API call will create a new template. ===Resource URL=== <pre>http://valt.example.com/api/v3/admin/templates</pre> ===Resource Information=== {|class="wikitable" |'''Met...")
 
(No difference)

Latest revision as of 13:28, 14 April 2020

This API call will create a new template.

Resource URL

http://valt.example.com/api/v3/admin/templates

Resource Information

Method POST
Headers Content-Type:application/json
Response Type JSON
Authentication Required Yes

Parameters

The JSON body must be properly formatted. All fields and values should be enclosed in double quotes and separated by a colon.

Field Name Description Required Example
name Template Name yes Clinical Information Template
type Template Type (Valid Values = info, marker, evaluation) yes information
hidden True = Template is hidden from view, False = Template is visible in web gui (No Quotes) no True
entity_name Default Field Name yes {"title":"Patient Number","type":"text","value":"1234567890"}
title Default Field Name (Recording Name if not specified) no Patient Number
type Default Field Type (Valid Values = text, dropdown) yes text
value Default Field Value (Blank if not specified) no 1234567890
fields Array of JSON objects containing specifications for additional fields. no [{"on":true,"required":true,"type":"text","name":"Patient Name","data":"John Doe"}]
on Field is Enabled (True or False) no true
required Field is Required (True or False) no false
type Field Type (Valid Values) yes text
name Field Name yes Patient Name
data Default Field Value no Jane Doe

Response

Code Reason
200 Template Created Successfully
400 Invalid Request (See Response for Specific Error)
401 Unauthorized
500 JSON Body Formatted Incorrectly
JSON Response
data
id ID number for the new template.

Examples

Request

The sample JSON body below is formatted with line breaks and indentation to make it easier to read. This is not required.

https://ivstest1.ad.ipivs.com/api/v3/admin/templates?access_token=e82632d19c523678fea3d1016c6df9e9
{
  "name":"Clinical Template",
  "type":"info",
  "entity_name": {
    "title":"Patient Number",
    "type":"text",
    "value":"1234567890"
  },
  "fields":[
    {
      "on":true,
      "required":true,
      "type":"text",
      "name":"Patient Name",
      "data":"John Doe"
    }
  ]
}

Successful Response

Sample response is shown with line breaks to make it more readable. Actual responses will not include line breaks.

{
"data":{
"id": 48
}
}

Failure Response

Sample response is shown with line breaks to make it more readable. Actual responses will not include line breaks.

{
"error":{
"code": 500,
"message": "Internal Server Error"
}
}