Php Azure easy tables-放置不起作用
我正在使用RESTAPI使用PHP发布、获取并放入我的easy表中。当我工作的时候,我无法投入工作 这是我的密码:Php Azure easy tables-放置不起作用,php,azure,azure-api-apps,Php,Azure,Azure Api Apps,我正在使用RESTAPI使用PHP发布、获取并放入我的easy表中。当我工作的时候,我无法投入工作 这是我的密码: $urlAzure = 'https://<account name>.azurewebsites.net/tables/<tableName>(PartitionKey="<key>",RowKey="<row key>")'; $dataAzure = array ( 'PartitionKey' => <k
$urlAzure = 'https://<account name>.azurewebsites.net/tables/<tableName>(PartitionKey="<key>",RowKey="<row key>")';
$dataAzure = array (
'PartitionKey' => <key>,
'Owner' => $_SESSION['username'],
'RowKey' => '<row key>',
'mediaUrl' => ''
);
$optionsAzure = array(
'http' => array(
'method' => 'PUT',
'content' => json_encode( $dataAzure ),
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$contextAzure = stream_context_create($optionsAzure);
$resultAzure= file_get_contents($urlAzure, false, $contextAzure);
if ($resultAzure === FALSE) {}
$urlAzure=”https://.azurewebsites.net/tables/(PartitionKey=“”,RowKey=“”)”;
$dataAzure=array(
“分区键”=>,
“所有者”=>$\u会话[“用户名”],
“RowKey'=>”,
“mediaUrl'=>”
);
$optionsAzure=array(
“http'=>数组(
'方法'=>'放置',
'content'=>json_encode($dataAzure),
'header'=>“内容类型:application/json\r\n”。
“接受:应用程序/json\r\n”
)
);
$contextAzure=stream\u context\u create($optionsAzure);
$resultAzure=file\u get\u contents($urlAzure,false,$contextAzure);
如果($resultAzure==FALSE){}
不幸的是,这是行不通的。经过一整天的试用,我终于发现了以下错误:
- HTTP错误400。请求的格式不正确
- 有时:项目不存在
我真的被卡住了。有人知道为什么它不起作用吗 似乎您正在移动应用程序的Easy Tables中实现表操作。如果我有任何误解,请随时告诉我 由于azure mobile apps Node.js服务器SDK提供了将存储在azure SQL数据库中的数据表作为WebAPI公开的机制,但它不公开
PUT
方法。有关更多信息,请参阅
如果您坚持使用
PUT
方法实现,您可以利用Easy API生成自定义API。感谢您的回答和链接。实际上,本例中的PUT方法是使用PATCH完成的。所以,多亏了你,我得到的是:)
$urlAzure=”https://.azurewebsites.net/tables//;
$dataAzure=array(
);
$optionsAzure=array(
“http'=>数组(
'方法'=>'补丁',
'content'=>json_encode($dataAzure),
'header'=>“内容类型:application/json\r\n”。
“接受:应用程序/json\r\n”
)
);
$contextAzure=stream\u context\u create($optionsAzure);
$resultAzure=file\u get\u contents($urlAzure,false,$contextAzure);
如果($resultAzure==FALSE){}
$urlAzure = 'https://<myAccountName>.azurewebsites.net/tables/<myTable>/<id>;
$dataAzure = array (
<my array to 'PATCH'>
);
$optionsAzure = array(
'http' => array(
'method' => 'PATCH',
'content' => json_encode( $dataAzure ),
'header'=> "Content-Type: application/json\r\n" .
"Accept: application/json\r\n"
)
);
$contextAzure = stream_context_create($optionsAzure);
$resultAzure= file_get_contents($urlAzure, false, $contextAzure);
if ($resultAzure === FALSE) {}