Posting records

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsPosting records
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
### Tutorial
 
 
 
POST one or more records to a SQL or NoSQL database. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
 
POST one or more records to a SQL or NoSQL database. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.
  
### API Endpoint
+
=== API Endpoint ===
  
 
<pre>POST https://{url}/api/v2/{api_name}/_table/{table_name}</pre>
 
<pre>POST https://{url}/api/v2/{api_name}/_table/{table_name}</pre>
  
### API Docs Screenshot
+
=== API Docs Screenshot ===
  
 
[[File:Swagger-post-records.png|1000px]]
 
[[File:Swagger-post-records.png|1000px]]
  
### Example - POST multiple contact records
+
=== Example - POST multiple contact records ===
  
 
* Table name: contact
 
* Table name: contact
* Body in API call: <pre>{
+
* Body parameter in API call:
 +
<pre>{
 
  "resource": [
 
  "resource": [
 
   {
 
   {
Line 27: Line 26:
 
}</pre>
 
}</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact</pre>
 
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact</pre>
 +
 +
== Posting via Axios ==
 +
<pre>
 +
axios({
 +
    method: 'post',
 +
    url: 'https://{url}/api/v2/db/_table/books',
 +
    headers: {'X-DreamFactory-Api-Key': ''},
 +
    data: {
 +
    "resource": [
 +
  {
 +
      "title": "Example"
 +
            }
 +
  ]
 +
  }
 +
    });
 +
</pre>

Latest revision as of 21:55, 25 March 2019

POST one or more records to a SQL or NoSQL database. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.

API Endpoint

POST https://{url}/api/v2/{api_name}/_table/{table_name}

API Docs Screenshot

Swagger-post-records.png

Example - POST multiple contact records

  • Table name: contact
  • Body parameter in API call:
{
 "resource": [
   {
     "first_name": "Alice",
     "last_name": "Jones"
   },
   {
     "first_name": "Bob",
     "last_name": "Simpson"
   }
 ]
}
  • Request URL:
    https://foo.com/api/v2/db/_table/contact

Posting via Axios

axios({
    	method: 'post',
    	url: 'https://{url}/api/v2/db/_table/books',
    	headers: {'X-DreamFactory-Api-Key': ''},
    	data: {
		    "resource": [
   				{
      				"title": "Example"
    			        }
  			]
  		}
    });