Following request works in the Postman UI (see image below). But the code generated for c# (RestSharp) fails with StatusCode: Unauthorized.
The request works in Postman before and after the code fails.
Generated code (which fails):
var client = new RestClient(āhttps://api.xyz.com/odata/Property?$filter=[ā¦ request filter here ā¦]ā);
var request = new RestRequest(Method.GET);
request.AddHeader(ācache-controlā, āno-cacheā);
request.AddHeader(āConnectionā, ākeep-aliveā);
request.AddHeader(āAccept-Encodingā, āgzip, deflateā);
request.AddHeader(āCookieā, āvisid_incap_1968058=sFqg5[ā¦ rest of cookie ā¦]ā);
request.AddHeader(āHostā, āapi.xyz.comā);
request.AddHeader(āPostman-Tokenā, ā7eb7d7a[ā¦ rest of postman token ā¦]ā);
request.AddHeader(āCache-Controlā, āno-cacheā);
request.AddHeader(āAcceptā, ā/ā);
request.AddHeader(āUser-Agentā, āPostmanRuntime/7.15.2ā);
request.AddHeader(āAuthorizationā, āBearer eyJ0eXAiO[ā¦ rest of access token ā¦]ā);
IRestResponse response = client.Execute(request);
Based on searches so far, have tried the following:
- replace 'Bearer ā with 'bearer ā
- replace 'Bearer ā with āJWTā or ājwtā
- remove the āAcceptā header
Works in Postman (note the data returned in the Body):
Any suggestions appreciated.