테이블 저장소 서비스에서 인세 트 테이블 엔티티 REST API를 실행하려고하지만 작동하지 않습니다.Azure 테이블 서비스 REST API 오류
나는 this doc를 언급했다. 내 요청 코드가 여기에있다
,
<?php
// storage account name
$account = "mystgaccount";
$tablestoragename = "mytablename";
$accessKey = "myaccesskey";
$date = gmdate('D, d M Y H:i:s T',time());
$api_version = "2015-12-11";
$url = "https://$account.table.core.windows.net/$tablestoragename";
$method = "POST";
$body = '{"Address":"MountainView","Age":23,"AmountDue":200.23,"[email protected]":"Edm.Guid","CustomerCode":"c9da6455-213d-42c9-9a793e9149a57833","[email protected]":"Edm.DateTime","CustomerSince":"2008-0710T00:00:00","IsActive":true,"[email protected]":"Edm.Int64","NumberOfOrders":"255","PartitionKey":"mypartitionkey","RowKey":"myrowkey"}';
$stringToSign = [
// VERB
$method,
// Content-MD5
'',
// Content-Type
'',
// Date
$date,
];
$stringToSign = array_merge($stringToSign, ["/$account/$tablestoragename"]);
$stringToSign = implode("\n", $stringToSign);
$signature = base64_encode(hash_hmac('sha256', $stringToSign, base64_decode($accessKey), true));
$headers = [
"x-ms-date:{$date}",
"x-ms-version:$api_version",
"Authorization:SharedKey $account:{$signature}",
"Content-Type: application/json",
];
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POSTFIELDS => http_build_query($body),
);
curl_setopt_array($ch, $proxy_options);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
var_dump($response);
echo curl_error($ch);
curl_close($ch);
?>
응답
"<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code>AuthenticationFailed</m:code><m:message xml:lang="en-US">Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:b93fe560-0002-0028-129a-571361000000
Time:2017-11-07T07:34:13.3303714Z</m:message></m:error>"
내가 관련 질문을 읽을 수는 있지만 아직 해결되지 않은 :(
당신이 어떤 아이디어가 있습니까?
AuthenticationFailed : 잘못된 계정 데이터입니까? – KimKulling
답장을 보내 주셔서 감사합니다, 김. 나는 나의 계좌를 확인했으나 틀린 것은 아니다. – ssk3