Reputation: 664
I am trying to fetch the list of members of any given organization on Github.com ... When I try it with Postman using the below Url and a Personal Access Token ... It works
"https://api.github.com/orgs/{orgname}/members"
But when I try it using my C# code with the same Url and Personal Access Token ... I get an empty Array instead ... What could I be missing? There are no errors since the HTTP Status Code is success ... But the Body of the response is an empty array like below: "[]"
Upvotes: 1
Views: 585
Reputation: 664
After @Martin Costello comment above I used fiddler to analyze the two requests ... One sent using Postman and the other from my code ... It turns out that the way I was setting the Authorization header was incorrect ... This is how I was sending it earlier
_baseClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", authInfo);
Vs.
_baseClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authInfo);
The second approach works ... Feel kind of silly ... But thanks to @Martin Costello for the hint to analyze the requests using a Network traffic analyzer
Upvotes: 0