title: REST Interacting with BigCommerce from VB EXCEL
body: <p>NOTE: Further research (and thick skin, and lots of coffee) has lead me <a href="https://stackoverflow.com/questions/16552731/bigcommerce-api-what-is-the-syntax-of-an-url-string-that-would-allow-me-to-down?rq=1">here</a> where it suggests that the store cannot receive the uid and pwd in the URL, and I gather from the PHP examples <a href="https://developer.bigcommerce.com/quickstarts/php" rel="nofollow noreferrer">here</a> that the transmission needs to be encrypted. Is this my problem? If so I have not been able to find anything on how to work around this. </p>
  
  <p>I would be happy if the open() command prompted the UID &amp; PWD window to open and I can manually input the values. Does anyone have a suggestion. Thanks!</p>
  
  <hr>
  
  <p>I am learning how to use the BigCommerce APIs and I am programming in VB / XL to be able to directly post / retrieve from all fields in the store's DB. </p>
  
  <p>I have never coded on this before (although I get around VB OK) and I am stuck. I have the following code:</p>
  
  <pre><code>Const URL As String = "https://www.myurl.com/api/v2/brands.json"
  
  Public Sub Test()
      Dim xmlHttp As Object
  
      Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
      xmlHttp.Open "GET", URL, False, "myid", "mytoken"
      xmlHttp.setRequestHeader "Content-Type", "application/json"
      xmlHttp.send
  
      Dim html As MSHTML.HTMLDocument
      Set html = New MSHTML.HTMLDocument
      html.body.innerHTML = xmlHttp.ResponseText
  
      Range("A1").Value = html.body.innerHTML
  
  End Sub
  </code></pre>
  
  <p>What I get back is "401" or more precisely:</p>
  
  <pre><code>[{"status":401,"message":"No credentials were supplied in the request."}]
  </code></pre>
  
  <p>The credentials are valid and working, as if I place the URL in my browser and submit it, the pop up for UID &amp; PWD comes up, and once I place the values I am using in the code, the resulting BRANDS list appears in the browser.</p>
  
  <p>Additionally, if I add a "rand num" to the URL to ensure the returned data is not cached as suggested <a href="http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp" rel="nofollow noreferrer">here</a>, then the request looks like this:</p>
  
  <pre><code>    xmlHttp.Open "GET", URL &amp; "&amp;t=" &amp; WorksheetFunction.RandBetween(1, 99), False, `"myid", "mytoken"`
  </code></pre>
  
  <p>and the response back from BC changes to:</p>
  
  <pre><code>406&lt;/STATUS&gt;&lt;MESSAGE&gt;The requested content type is not available.&lt;/MESSAGE&gt;&lt;/ERROR&gt;&lt;/ERRORS&gt; 
  </code></pre>
  
  <p>I have also tried this (where UID and PWD are the correct values):</p>
  
  <pre><code>xmlHttp.Open "GET", URL &amp; "&amp;user=UID" &amp; "&amp;password=PWD", False
  </code></pre>
  
  <p>and i get:</p>
  
  <pre><code>406&lt;/STATUS&gt;&lt;MESSAGE&gt;The requested content type is not available.&lt;/MESSAGE&gt;&lt;/ERROR&gt;&lt;/ERRORS&gt; 
  </code></pre>
  
  <p>Can anyone help me understand pls. I have followed examples at MSDN, but I am still stuck. The BC API site is poor in examples (none actually!) for VB.</p>
  
  <p>Thank you</p>