3
votes

I am trying insert a dumb entity into an Azure Storage Table in javascript using Insert Entity API. I enabled CORS and managed to get my request authenticated, but my dead simple request is failing with One of the request inputs is not valid. message

Here is more details on the request:

Accept:application/json;odata=nometadata
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Authorization:SharedKey <account>:<secret>
Cache-Control:no-cache
Connection:keep-alive
Content-Length:70
Content-type:application/json
DataServiceVersion:3.0;NetFx
Host:<account>.table.core.windows.net
If-Match:*
MaxDataServiceVersion:3.0;NetFx
Origin:http://localhost:6091
Referer:http://localhost:6091/
x-ms-date:Fri, 08 Jan 2016 06:23:29 GMT
x-ms-version:2013-08-15

Here is the request payload:

{Message: "test", RowKey: "myrowkey", PartitionKey: "mypartitionkey"}

And here is the response, which has a HTTP status 400:

Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:x-ms-request-id,x-ms-version
Content-Type:application/json;odata=nometadata;streaming=true;charset=utf-8
Date:Fri, 08 Jan 2016 06:23:30 GMT
Server:Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
x-ms-request-id:4994f291-0002-004d-1cdd-49d7ff000000
x-ms-version:2013-08-15

with a body:

{"odata.error":{"code":"InvalidInput","message":{"lang":"en-US","value":"One of the request inputs is not valid.\nRequestId:4994f291-0002-004d-1cdd-49d7ff000000\nTime:2016-01-08T06:23:30.4716844Z"}}}

I have seen people complaining about this non-descriptive error message. However, I am pretty sure this request payload is fine. RowKey and PartitionKey do not have special characters and Message field doesn't have to provide its odata type (but believe me, I tried that too). I tried the payload provided as an example too, still the issue is there.

2
We use JavaScript/AJAX/CORS to manage table data extensively in our application. I just tried it there with your request payload and it worked just fine. Looks like some other issue. Will it be possible for you to share some code?Gaurav Mantri
If possible, please share exactly the json body you tried to upload.Fabrizio Accatino

2 Answers

2
votes

I found the solution by trial and error method. The request header If-Match:* was the problem. I removed that header and it started working.

Azure definitely needs to get more explicit and clear about their documentation and error messages.

0
votes

If you check the example JSON body in the docs you linked to for insert entity you'll notice the keys should be in quotes. Try sending a body like the following:

{"Message": "test", "RowKey": "myrowkey", "PartitionKey": "mypartitionkey"}