Click here to Skip to main content
15,908,931 members

Comments by Muhmmad Nauman (Top 2 by date)

Muhmmad Nauman 25-Jan-21 5:27am View    
Thanks Richard for your support..
var client = new HttpClient();
client.BaseAddress = new Uri("https://api.sandbox.paypal.com");
var authHeader = new AuthenticationHeaderValue("Bearer", accessToken);
client.DefaultRequestHeaders.Authorization = authHeader;
client.DefaultRequestHeaders
.Accept
.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = client.GetAsync("/v1/billing/subscriptions/" + "I-BW452GLLEP1G").Result;
if (response.IsSuccessStatusCode)
{
string responseBody = response.Content.ReadAsStringAsync().Result;
JObject jsonConvertedResponseString = JObject.Parse(responseBody);
return new
{
Success = true,
Message = "",
Data = jsonConvertedResponseString
};
}
return new
{
Success = false,
Message = "Something went wrong.",
Data = DBNull.Value
};
This code working fine for me...
Muhmmad Nauman 25-Jan-21 4:31am View    
Yes, I'm getting access_token as response from paypal token api i.e https://api.sandbox.paypal.com/v1/oauth2/token and passing access_token as parameter in above my api function.
And I'm getting error "The remote server returned an error: (401) Unauthorized." on line (HttpWebResponse)request.GetResponse();