0

I'm sending query to documentDB by:

    client = new DocumentClient(END_POINT,
            MASTER_KEY, ConnectionPolicy.GetDefault(),
            ConsistencyLevel.Session);

  FeedResponse<Document> documents = client.queryDocuments("/dbs/mydb/colls/mycoll", query, null);

And then when i try to read response from server

  for (Document document : documents.getQueryIterable()) 

I'm getting following exception:

{"code":"Unauthorized","message":"The input authorization token can't serve the request. Please check that the expected payload is built as per the protocol, and check the key being used. Server used the following payload to sign: 'post\ndocs\ndbs/mydb/colls/mycoll\nsun, 12 mar 2017 08:40:40 gmt\n\n'\r\nActivityId: f40f31cf-f11c-4052-94b4-992cfdd271f5"}

request headers:

"x-ms-date" -> "Sun, 12 Mar 2017 08:40:40 GMT"
"x-ms-documentdb-isquery" -> "true"
"Accept" -> "application/json"
"Content-Type" -> "application/query+json"
"authorization" -> "type%3Dmaster%26ver%3D1.0%26sig%3DiQvTEAbWWK8pvHvr9RAqp2kjiechyPp6S5kvxT4g6Kw%3D%0A"

Other request values that my be important:

resourceid = mycoll
Path = /dbs/mydb/colls/mycoll/docs/
resourceType = Document
IsMedia = false

Please help me I have no idea what can i do to fix this error

1 Answer 1

0

Solution was switching from android Base64 implementation to apache.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello, could you please describe how exactly did you switch to apache implementation? Because I'm facing the same problem but with Spring framewok. Thank you. stackoverflow.com/questions/43026784/…
@miskohut in quite ugly way -downlaod documentdb source code then go into apache base64 class sourcecode and copy paste it under another namespace this way android won't replace it. You can try it but i'm not sure it is case for spring framework as it shouldn't override documentdb classes. Anyway I droped this solution and switched to web api server provided with app service as a middle layer. Under c# everything works like charm without any problems. Also posted here unauthorized problem was last step of my modification to this library to make it work under android.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.