API 開發指南
遇到問題了嗎?不用擔心,答案都在這。
全站搜尋

Creating a New Entry

If you are not using simple HTML forms to create entries on Ragic, you will need to create API requests to create the entries. The endpoints for writing to a form is the same as reading them, but you issue a POST request instead of a GET request.

The API now supports JSON data, and it is the recommended way to make HTTP requests.

To POST JSON data, you need to change Body settings to raw JSON, as the image below.

What you need to do is use the field ids of the fields as name, and the values that you want to insert as parameter values.

Please note that your user will need write access to the form for this to work.


curl -F "2000123=Dunder Mifflin" \

-F "2000125=1-267-922-5599" \

-F "2000127=Jeff Kuo" \

-F "api=" \

-H "Authorization:Basic YOUR_API_KEY_GOES_HERE" \

https://www.ragic.com/demo/sales/1

The equivalent JSON format is as below,


{

"2000123": "Dunder Mifflin",

"2000125": "1-267-922-5599",

"2000127": "Jeff Kuo",

}

If the field is a multiple selection that can contain multiple values, you can have multiple parameters with the same field id as names. If the field is a date field the value will need to be in the format of yyyy/MM/dd or yyyy/MM/dd HH:mm:ss if there's a time part. So a request would look like this:


curl -F "2000123=Dunder Mifflin" \

-F "2000125=1-267-922-5599" \

-F "2000127=Jeff Kuo" \

-F "1000001=Customer" \

-F "1000001=Reseller" \

-F "2000133=2018/12/25 23:30:00" \

-F "api=" \

-H "Authorization:Basic YOUR_API_KEY_GOES_HERE" \

https://www.ragic.com/demo/sales/1

The equivalent JSON format is as below,

the squre brackets for the field ID 1000143 allows for multiple values in one statement.

{

"2000123": "Dunder Mifflin",

"2000125": "1-267-922-5599",

"2000127": "Jim Halpert",

"1000001": ["Customer", "Reseller"],

"2000133": "2018/12/25 23:30:00"

}

If you would like to insert data into the subtables at the same time, you will need a slightly different format for the fields in the subtables because Ragic needs a way to determine if the field values belong to the same entry in a subtable.

If the field values are in the same subtable row, assign them with the same negative row id with each other. It can be any negative integer. It's only a way to determine that they are in the same row.

2000147_-1=Bill

2000148_-1=Manager

2000149_-1=billg@microsoft.com

2000147_-2=Satya

2000148_-2=VP

2000149_-2=satyan@microsoft.com

The whole request would look like this:


curl -F "2000123=Dunder Mifflin" \

-F "2000125=1-267-922-5599" \

-F "2000127=Jeff Kuo" \

-F "1000001=Customer" \

-F "1000001=Reseller" \

-F "2000133=2018/12/25 23:30:00" \

-F "2000147_-1=Bill" \

-F "2000148_-1=Manager" \

-F "2000149_-1=billg@microsoft.com" \

-F "2000147_-2=Satya" \

-F "2000148_-2=VP" \

-F "2000149_-2=satyan@microsoft.com" \

-F 'api=' \

-H "Authorization:Basic YOUR_API_KEY_GOES_HERE" \

https://www.ragic.com/demo/sales/1

The equivalent JSON format is as below,

{

"2000123": "Dunder Mifflin",

"2000125": "1-267-922-5599",

"2000127": "Jim Halpert",

"1000001": ["Customer", "Reseller"],

"2000133": "2018/12/25 23:30:00"

"_subtable_2000154": {

"-1": {

"2000147": "Bill",

"2000148": "Manager",

"2000149": "billg@microsoft.com"

},

"-2": {

"2000147": "Satya",

"2000148": "VP",

"2000149": "satyan@microsoft.com"

}

}

}

If you would like to populate a file upload field, just make sure that the request encoding type is a multipart/form-data. The HTML equivalent would be setting enctype='multipart/form-data'

With a multipart request, you can put the file in your request, and just put the file name as the field value.


1000088=test.jpg

回最上面 目錄

馬上註冊
免費試用 Ragic!

用 Google 帳號註冊

立即科技 Ragic, Inc.
02-7728-8692
台北市中正區南昌路二段81號9樓