How to convert this curl command to restsharp?
curl -X POST \
--header "Authorization: Bearer SomeToken" \
--header "_Id: SomeId" \
--data-urlencode 'keys: name, age' \
https://api.SomeDomain.com/object-storage/classes/query/Player
I've tried this:
RestClient client = new RestClient("https://api.SomeDomain.com");
RestRequest request = new RestRequest("/object-storage/classes/query/hotels", Method.POST);
request.AddHeader("_Id", "SomeId");
request.AddHeader("Authorization", "Bearer " + SomeToken);
request.AddParameter("application/json", "{\"keys\" : \"name\" ,\"age\"}");
var response = client.Execute(request);
I don't have any idea how to convert this line:
--data-urlencode 'keys: name, age' \
EDIT 1:
ok as @Evk said i try the curl commond :
curl -X POST \
--header "Authorization: Bearer SomeToken" \
--header "X-Backtory-Object-Storage-Id: SomeId" \
--data-urlencode 'keys:Name' \
--trace-ascii /dev/stdout
https://api.backtory.com/object-storage/classes/query/hotels
this is what trace print :
=> Send header, 908 bytes (0x38c)
0000: POST /object-storage/classes/query/hotels HTTP/1.1
0034: Host: api.backtory.com
004c: User-Agent: curl/7.52.1
0065: Accept: */*
0072: Authorization: Bearer SomeToken
030d: X-Backtory-Object-Storage-Id: SomeId
0345: Content-Length: 17
0359: Content-Type: application/x-www-form-urlencoded
038a:
=> Send data, 17 bytes (0x11)
0000: %27keys%3AName%27
and the error :
{
"timestamp" : "2017-01-13T13:59:29.883UTC",
"status" : 500,
"error" : "Internal Server Error",
"exception" : "com.google.gson.JsonSyntaxException",
"message" : "org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 19 path $",
"path" : "/classes/query/hotels"
}
and for more detail i have no control at server side !