2016-01-11 64 views
1

我目前正在嘗試使用Azure的新「簡單表格」。我已經讀過它是完全RESTful的,我完全有能力「獲取」表中的數據,但不知何故,我不知道如何插入我嘗試使用「POST」的數據,但無論我把什麼放入「數據「的一部分,它總是說Azure「Easy Tables」Rest API主體

{"error":"An item to insert was not provided"} 

有人可以告訴我身體應該是什麼樣子嗎?我真的越來越絕望這裏...

我的表看起來像這樣:

id | createdAt | updatedAt | version | deleted | orgID 

通知,只有ORGID是我插入一列提前

謝謝!

+0

在哪個平臺上工作?每個應用程序(Mobiel,Web,API)都有一個SDK可以讓你的開發生活更快樂:) –

+0

你有一個「get」的例子嗎?我只能獲取所有記錄,但我想查詢特定字段 – user230910

回答

2

這裏是一個請求會是什麼樣使用curl:

curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{ 
    "id" :"1111", 
    "orgID" : "1234" 
}' "http://<your_site_host>/tables/<tablename>?zumo-api-version=2.0.0" 

希望它能幫助。

1
$urlAzure = "https://<your_app>.azurewebsites.net/tables/<your_table>"; 
$data = array (
    '<column1>' => <some_text>, 
    '<column2>' => <some_text> 
); 
$options = array(
    'http' => array(
     'method' => 'POST', 
     'content' => json_encode($data), 
     'header'=> "Content-Type: application/json\r\n" . 
       "Accept: application/json\r\n" 
    ) 
); 
$context = stream_context_create($options); 
$result= file_get_contents($urlAzure, false, $context); 
if ($result === FALSE) { /* Handle error */ }