title: How to integrate PayPal subscription API using ASP .NET MVC
body: <p>I followed this PayPal document <a href="https://developer.paypal.com/docs/api/subscriptions/v1" rel="nofollow noreferrer">https://developer.paypal.com/docs/api/subscriptions/v1</a> for subscription API. I want to call this API <a href="https://api.sandbox.paypal.com/v1/billing/subscriptions/$%7BsubscriberId%7D" rel="nofollow noreferrer">https://api.sandbox.paypal.com/v1/billing/subscriptions/${subscriberId}</a> using ASP .NET MVC. This API needs authorization token using PayPal clientID and secretID which I've successfully created the token but I've problem in calling subscription API.</p>
  <pre><code>curl -v -X GET 
  https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G \
  -H &quot;Content-Type: application/json&quot; \
  -H &quot;Authorization: Bearer Access-Token&quot;
  </code></pre>
  <p>Also I've just call this API using react JS and I'm getting desire result. But in ASP .NET MVC how to call this subscription API ?
  React JS Code:</p>
  <pre><code>async function checkPayPalPaymentStatus(subscriberId, access_token) {
    var token = `Bearer ${access_token}`;
    return await fetch(
      `https://api.sandbox.paypal.com/v1/billing/subscriptions/${subscriberId}`,
      {
        method: &quot;GET&quot;,
        headers: {
          Accept: &quot;application/json&quot;,
          &quot;Content-Type&quot;: &quot;application/json&quot;,
          Authorization: token,
        },
      }
    ).then((response) =&gt; response.json());
  }
  </code></pre>
  <p>ASP .NET MVC Code:</p>
  <pre><code>[HttpGet]
          [Route(&quot;api/paypal/checkPayPalPaymentStatus&quot;)]
          public async Task&lt;object&gt; CheckPayPalPaymentStatus(string accessToken)
          {
              try
              {
                  //
                  string url = &quot;https://api.sandbox.paypal.com/v1/billing/subscriptions/&quot; + &quot;I-BW452GLLEP1G&quot;;
                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                  request.Headers[&quot;Authorization&quot;] = &quot;Bearer &quot; + Convert.ToBase64String(Encoding.Default.GetBytes(accessToken));
                  request.Accept = &quot;application/json&quot;;
                  request.Method = &quot;GET&quot;;
                  request.ContentType = &quot;application/json&quot;;
  
                  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                  Stream streamResponse = response.GetResponseStream();
                  StreamReader streamRead = new StreamReader(streamResponse);
                  string responseString = streamRead.ReadToEnd();
                  JObject jsonConvertedResponseString = JObject.Parse(responseString);
                  return new
                  {
                      Success = true,
                      Message = &quot;&quot;,
                      Data = jsonConvertedResponseString
                  };
              }
              catch (Exception ex)
              {
                  return new
                  {
                      Success = false,
                      Message = ex.Message,
                      Data = DBNull.Value
                  };
              }
          }
  </code></pre>