Gold R8 API interface

The AbleCommerce data exchange is a useful feature for importing and updating data. The Data Exchange feature (just like the 7.0.x data port) is only supported via the forums or paid support.

*** BACKUP YOUR DATABASE BEFORE ATTEMPTING TO USE THESE TOOLS ***
Post Reply
msandin
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Tue Jul 15, 2014 11:29 pm

Gold R8 API interface

Post by msandin » Fri Jan 16, 2015 1:04 pm

Folks,

In trying to work around some perceived issues, I decided to try the AbleCommerce Gold Web API interface to accomplish my tasks. I need to be able to update products so I wish to use the admin controller. The documentation says SSL and authorization is required. I understand and can comply with SSL, but I don't see anything about how I specify authorization. I would guess inclusion of something such as password="*******" to be include in the command.

This is the command I am testing to extract data on ProductId number 309. I expect it to return all the data for that product for further processing.

lcurl = "https://%%%%%%.com/api/AdminProducts/{309}/List"

So the question is "How do I specify Authorization?

Thanks

Miles Sandin
msandin@sSheltieSys.com

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Gold R8 API interface

Post by jguengerich » Fri Jan 16, 2015 1:27 pm

I think it uses HTTP Basic Authentication. So you'd have to add a Basic Authentication header to the http request.
Jay

msandin
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Tue Jul 15, 2014 11:29 pm

Re: Gold R8 API interface

Post by msandin » Mon Feb 02, 2015 12:46 pm

Folks,

I guess I am dense! Could you insert header code into this for me. Use "username" (without quotes) and "cGFzc3dvcmQ=" (without quotes which I think is base64 encoding of "password" [again without quotes])
=============================

lcurl = "https://%%%%%%.com/api/AdminProducts/{309}/List"

Also, the Productid is 309 in my test site. Should the braces be there? I created this using info from the AbleCommerce Gold Web Api - AbleCommerce Wiki document...


Thanks so much for your help...

Miles Sandin
msandin@SheltieSys.com
Bridgewater VA

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Gold R8 API interface

Post by jguengerich » Mon Feb 02, 2015 1:21 pm

The braces should not be there, and you don't need /List.

The Basic authorization header is not part of the url string. It is a header in the HTTP request. The correct way of creating the header is explained here: http://en.wikipedia.org/wiki/Basic_acce ... entication (see Client side). You create the string "username:password" (include the colon), then convert that to base 64. The value for the Authorization header is "Basic YourBase64ValueHere" (include the space). I don't know what you are using to create the http request, so I can't give you specifics about how to add an Authentication header to it and set the header's value.

You can see the API help and test the API by going to yourstore/api/help, then choosing one of the commands and clicking the "Test API" button in the bottom right corner. You will see a form to fill in any required parameters, with a Send button. Your browser will prompt you for the username and password the first time you click Send for one of the Admin functions. The browser is reacting to the server's HTTP 401 (Not authorized) response code (which in this case includes an Authenticate header specifying Basic mode) by asking you for the username and password and sending the request again with your info in an Authorization header. It will remember this header and keep sending it for future requests until you close your browser. If you turn on your browser's developer tools, you should be able to view the full http requests and responses.
Jay

msandin
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 30
Joined: Tue Jul 15, 2014 11:29 pm

Re: Gold R8 API interface

Post by msandin » Wed Feb 04, 2015 12:00 pm

Jay, I really appreciate your help.

Our in-house system is written in MS Visual FoxPro Version 9.

Here is code that I use to handle an address verification via USPS web api's

lohttp = createobject("MSXML2.XMLHTTP.6.0")
xuid = "*********" && the asterisks are replaced with USPS login info.

===================================================
lcurl = ;
'http://production.shippingapis.com/Ship ... erify&XML=' + ;
'<AddressValidateRequest%20USERID="' + xuid + '">' + ;
'<Address ID="0">' + ;
'<Address1>' + upper(alltrim(f02.badd2)) + '</Address1>' + ;
'<Address2>' + upper(alltrim(f02.badd1)) + '</Address2>' + ;
'<City>' + upper(alltrim(f02.bcity)) + '</City>' + ;
'<State>' + upper(alltrim(f02.bstate)) + '</State>' + ;
'<Urbanization>' + upper(alltrim(f02.burban)) + '</Urbanization>' + ;
'<Zip5>' + left(f02.bzip,5) + '</Zip5>' + ;
'<Zip4>' + right(f02.bzip,4) + '</Zip4>' + ;
'</Address>' + ;
'</AddressValidateRequest>'

release minfo99
minfo99 = lcurl

lohttp.open("Get", lcurl, 0)
lohttp.send()

minfo99 = lohttp.responsetext
============================================

The variable minfo99 contains the xml code from USPS. I then parse that and take appropriate actions.

jguengerich
Commodore (COMO)
Commodore (COMO)
Posts: 436
Joined: Tue May 07, 2013 1:59 pm

Re: Gold R8 API interface

Post by jguengerich » Wed Feb 04, 2015 12:40 pm

I'm not sure if you are asking another question. I don't have any experience with Visual FoxPro, so I can't give you any more info about your original question than I already have. You will need to find out how to add an Authorization header to your http request in Visual FoxPro, and set it's value as I described.
Jay

Post Reply