Retrieving data from Fastspring

I’m trying to retrieve data from Fastspring. I’ve set up API credentials with username and password. I’ve modified the example URLConnectionGet from the Xojo examples. I changed the url to https://api.fastspring.com/accounts/ to get a list of customer.

The code I changed to:

WebConnection.RequestHeader("Username:") = EncodeBase64("xxx")
WebConnection.RequestHeader("Password:") = EncodeBase64("xxx")
WebConnection.RequestHeader("User-Agent:") = "Moth Software"
dim content As String = WebConnection.SendSync("GET", URLField.Text, 30)
ContentArea.Text = content

The only result I get is a 401 the HeadersReceived event. What am I doing wrong?

Xojo 2021r2.1 on Monterey.

I wrote a small app to give me desktop notifications from the API. I can check how it works when I’m back at my desk. I finally got around to that eye surgery.

I thiiiiiiiink you concatenate the username and password before you base 64 them? That’s just from memory, I am happy to confirm later when I can.

2 Likes

Header names should not include the trailing colon.

I get the same result without the colons.

I couldn’t find any updated versions of authentication in the FastSpring docs, so this should still work.

Protected Function AuthenticationString(tsUsername as String, tsPassword as String) as String
  dim tsJoined as String = tsUsername + ":" + tsPassword
  return EncodeBase64(tsJoined, 0)

End Function

and

dim toConn as new URLConnection
toConn.RequestHeader("Authorization") = "Basic " + AuthenticationString

Clearly you’d want to cache the authentication string, and this second bit of code won’t work copy and paste (it needs params). But I have a feeling this should help you get running. If you still have trouble, don’t hesitate to ask.

1 Like

I’ve never known I wanted to use FastSpring’s api before, but I wanted to see if I could do it. LOL Tim’s solution works for me (although /accounts isn’t what I need, it’s /orders).

1 Like

Glad to help! I tried to release the notification app on the MAS but the Apple reviewers were having none of the “external link to a signup” and I wasn’t about to cave to their stupidity, so there’s just one less useful app in the world.

1 Like

Dang, there’s a ton less apps in the world because of Apple’s App Store Reviewers. I’ve witnessed several devs build an app and then give up when fighting Apple.

Can’t wait for someone who doesn’t make millions from manipulating the share price to run Apple.