Reputation: 13
I am currently experimenting with Azure's new "Easy Tables". I have read that it's completely RESTful and I am fully capable of "GET"ting the data in the tables but somehow, I'm not sure how to insert the data I tried using "POST" but no matter what I put into the "data" part of my curl request, it always says
{"error":"An item to insert was not provided"}
Can someone tell me how the body should look like? I'm really getting desperate here...
My table looks like this:
id | createdAt | updatedAt | version | deleted | orgID
notice that only orgID is a column inserted by me
Thanks in advance!
Upvotes: 1
Views: 817
Reputation: 674
$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 */ }
Upvotes: 1
Reputation: 12538
Here is what a request would look like using 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"
Hope it helps.
Upvotes: 2