title: jet.com Partner API - Rest, JSON, RestSharp?
body: <p>I have a custom order management system, written in VB.net.  I now need to use the jet.com partner api for integration with them.  I'm sure this isn't hard for you web experts out there, but I don't have much experience with RESTful calls to apis.</p>
  
  <p>The <a href="https://developer.jet.com/security" rel="nofollow noreferrer">documentation I have</a> says:</p>
  
  <blockquote>
    <p>Jet API Security Flow<br>
    The following security flow is the assumed flow for accessing Jet API functions that require authorization:</p>
    
    <p>User submits his/her credentials over SSL/TLS to Jet API <code>/api/Token</code> endpoint  via HTTPS POST request, like below:</p>
  
  <pre><code>POST https://merchant-api.jet.com/api/Token HTTP/1.1 
  Host: merchant-api.jet.com 
  Content-Type: application/json; charset=utf-8 
  Content-Length: 42 
  
  {"user":"dummy@jet.com","pass":"XXXXXXXX"} 
  </code></pre>
    
    <p><code>/api/Token</code> endpoint is a single point of authentication for Jet API users. Therefore, it does not require either authentication or authorization.</p>
    
    <p>If the user successfully authenticated, the security (bearer) token is returned back over SSL/TLS carrying claims associated with the user encoded and signed:</p>
  
  <pre><code>HTTP/1.1 200 OK 
  Cache-Control: no-store 
  Pragma: no-cache 
  Content-Length: XXX 
  Content-Type: application/json; charset=utf-8 
  Server: Microsoft-IIS/8.0 
  Set-Cookie: auth0=XXX...XX; path=/; secure; httponly 
  Server: nginx/1.7.1 
  X-AspNet-Version: 4.0.30319 
  X-Powered-By: ASP.NET 
  Date: Wed, 06 Aug 2014 13:50:17 GMT 
  Set-Cookie: SERVERID=03-4BRURJ6FFLMCK; path=/ 
  
  {"id_token":"XXX...XX","access_token":"XXX...XX","token_type":"bearer"} 
  </code></pre>
    
    <p>Token is contained in JSON node id_token that should be used in the following HTTP requests to Jet API as authorization vehicle (see article 4 below) until it expires or gets refreshed.</p>
    
    <p>If not authenticated at the /api/Token endpoint, the user gets back HTTP response carrying header <code>HTTP/1.1 401 Unauthorized</code>.
    Having the above bearer token, the user then should provide it when calling other Jet API endpoints as part of HTTPS requests within Authorization header. This header has the following form: Authorization: Bearer
    If the user has proper permissions associated with the token he/she will be allowed to access the endpoints and/or specific data assigned by those permissions. The request will be executed and response will be defined by the correspondent called API function, otherwise HTTP/1.1 401 Unauthorized response is returned back.</p>
    
    <p>Bearer tokens provided to Jet API users have a limited lifetime. However, until the token expires, the bearer token will be a full substitute for user credentials, so the token must be handled as private cryptographic material.</p>
  </blockquote>
  
  <p>Can anyone show me some sample code to do this in C#?  I was thinking using RestSharp would be helpful, but don't have any experience with that either.</p>
  
  <p>For their API I need:</p>
  
  <ol>
  <li>Authorize my API calls</li>
  <li>Upload products in JSON</li>
  <li>Retrieve order information</li>
  <li>etc.</li>
  </ol>
  
  <p>So, I'm stuck at the first phase, authorizing my API calls.</p>