api - Getting Unauthorized error when trying to execute the RestSharp request that retrieves data from ArangoDB -
if send http request through postman works , result. same not working , getting unauthorized when execute through restsharp.
below code snippet:
var client = new restclient( "http://username:password@localhost:port/_db/databasename/_api/simple/all"); var request = new restrequest(method.put); request.addheader("content-type", "application/json"); request.addparameter("application/json", "{\n \"collection\":\"collectionname\"\n}", parametertype.requestbody); irestresponse response = client.execute(request); return response;
according the restsharp wiki cannot specify authentication parameters via url:
var client = new restclient("http://example.com"); client.authenticator = new simpleauthenticator("username", "foo", "password", "bar"); var request = new restrequest("resource", method.get); client.execute(request);
in general idea in such case drop https, , use wireshark or ngrep inspect whats going on on wire:
get /_db/_system/_api/version?details=true http/1.1 host: 127.0.0.1 connection: keep-alive user-agent: arangodb accept-encoding: deflate authrization: basic cm9vddo=
to inspect actualy generated authentication headers.
Comments
Post a Comment