POST - AppDaddy-Software-Solutions-Inc/framework-markup-language GitHub Wiki
<POST/> : Http
The POST
datasource widget is used to create or update data via an API endpoint using the standard HTTP POST method. Like all HTTP methods, POST
can also return bindable response data upon succeeding. Data can be posted and returned as JSON or XML(default).
- Overview
- Usage
- Attributes :: HttpDataSource (inherited attributes)
- Methods :: HttpDataSource (inherited attributes)
- Examples - Example #1 - (example 2) - (example 3)
- Properties
- Examples
- Other Widgets You May Find Useful:
The POST
widget is used to automatically build a posting document within a FORM
using FormField
widget id
's and the <FormID>.complete()
event, or inside of the framework using <id>.start()
on the datasource and manually building the body
from bindings and xml tags. All HTTP datasources can have multiple TRANSFORM
widgets to selectively transform data that is returned from the call.
- To create or update data via an api.
- To receive response data after a create or update task.
- To make an http post method call.
- FormField IDs will be the surrounding their value when
complete()
orsave()
is called on the form. - If the method should be idempotent, consider the
PUT
widget.
Attributes :: HttpDataSource (inherited attributes)
Name | Type | Default | Description | Req |
---|---|---|---|---|
body | string | null | The tags wrapping a custom posting body for the POST widget. | |
root | string | FORM | The outer wrapper of the posting document tags. Used as an XML tag when defining a document manually. This will also define the outer wrapper of the returned data as does GET(./GET) |
Methods :: HttpDataSource (inherited attributes)
Name | Type | Default | Description | Req |
---|
This example demonstrates a simple posting to an endpoint using the data collected from the INPUT values prior to hitting the SUBMIT button.
<POST id="P1" url="api/users">
<BODY>
<USER>
<name>{username}</name>
<age>{age}</age>
<gender>{gender}</gender>
</USER>
</BODY>
</POST>
<INPUT id="username"/>
<INPUT id="age"/>
<INPUT id="gender"/>
<BUTTON onclick="P1.fire()" label="Submit!"/>
The following posting body is sent to api/users.
<USER>
<name>Joe Test<name>
<age>20<age>
<gender>male<gender>
</USER>
This example demonstrates a single post tied to a form.
<POST id="P1" url="api/users/" root="ROOT">
<FORM post="F1" post="P1"/>
<INPUT id="username"/>
<INPUT id="age"/>
<INPUT id="gender"/>
</FORM>
<BUTTON onclick="F1.complete()" label="Save the Form!"/>
When the form is completed, the following posting body is submitted to /api/users.
<ROOT>
<username>Joe Test<username>
<age>20<age>
<gender>male<gender>
</ROOT>
This example demonstrates a 2 posts tied to a single form. Post P1 has the uses the form default posting body and post P2 has a custom body.
<POST id="P1" url="http://someothersite.com/api/users/" root="USER">
<POST id="P2" url="api/users/">
<BODY>
<PERSON username="{username}" age="{username}" male="=({gender} = 'm' ? true : false)"/>
</BODY>
</POST>
<FORM post="P1,P2"/>
<INPUT id="username"/>
<INPUT id="age"/>
<INPUT id="gender"/>
</FORM>
<BUTTON onclick="F1.complete()" label="Save the Form!"/>
When the form is completed, the following posting body is submitted to http://someothersite.com/api/users/.
<USER>
<username>Joe Test<username>
<age>20<age>
<gender>male<gender>
</USER>
and the following body is sent to api/users.
<PERSON username="Joe Test" age="20" male="true"/>
Name | Type | Default | Description | Req |
---|---|---|---|---|
status | string | idle |
The status of the broker, returns error , success , idle , or exception . |
|
statuscode | string | null | Returns the http status code. | |
httpstatus | string | null | Returns the generic message associated with the http status code. |
<POST id="P1" url="api/users/" tti="25s" body="USER"/>
<POST id="P2" url="http://someotherwebsite/api/users/" tti="25s" body="USER"/>
<BUTTON onclick="complete('saveform')" label="Save Form!"/>
<FORM id="saveform" post="P1,P2">
<INPUT id="username"/>
<INPUT id="age"/>
<INPUT id="gender"/>
</FORM>