Prestashop API

Hi!

does anybody make an integration with the Prestashop API?
I found all examples in php and xml…

Their API seems to be documented fairly well as they explain all of their routes and explaining that their REST api is a CRUD service that uses the XML or JSON data structure. The api auth looks easy as it appears to be an api key (you get from them I assume) that you pass in the auth header.

You can achieve this a number of ways. You can roll your your own Xojo code base by using URLConnection and then handling the data parsing (etc) or you can use MBS plugins or Chilkat Plugins (Chilkat.Rest object) which make it easier for you to implement in your project.

Good luck!

I’ve read that tutorials, unfortunately there are only php examples
I’m using CURLSMBS but I’m getting problems with the authorization key in the URL

Ciao Ciro,
Can you post your code? Also have you tried connecting to your API with postman to validate the api is working for the api key you have?

Io uso una URLConnection per connessione API.

Grazie

Mike,

the problem is that I’m not able to autenthicate without using this method (tried to put in the header but no success)

/?ws_key=myapikey

but using this method cannot permit to use another property (such as ?display=full,…) because it reports that apikey is in wrong format (tried also with postman)

'dim datas() as string
'
'datas.Append "Content-Type: application/json"
'datas.Append "user_key: ncssrl"
'datas.Append "Access_token: TaRGeT1997"

dim c as new CURLSMBS
dim header() as string
dim e as integer
c.OptionGet = true
c.OptionVerbose = true
c.OptionSSLVersion = c.kSSLVersionTLSv12
c.CollectHeaderData = true


'header.Append("Authorization: Basic "+TxtApiKey.Text.Trim)
header.Append("Output-Format: JSON")
'header.Append("display: full")

c.SetOptionHTTPHeader(header)
'
'c.OptionURL =  TxtApiKey.Text.Trim+"@"+TxtShopUrl.text.trim+"/api/'?output_format=JSON"
''break
'e = c.Perform
'DebugTextArea.Text = c.DebugData
'ResultTextArea.Text = c.OutputData
'c.ClearData

'xml
'ok
c.OptionURL =  "https://www."+TxtShopUrl.text.trim+"/api/"+SpTabella.Text.Trim+"?schema=blank"+"/?ws_key="+TxtApiKey.Text.Trim
break
e = c.Perform
'
DebugTextArea.Text = c.DebugData
ResultTextArea.Text = c.OutputData

'c.ClearData

//facciamo il parsing del Json
'Dim json As Auto
'json = Xojo.Data.ParseJSON( c.OutputData.ToText)
'Break

Multiple arguments in a URL are delimited by an ampersand: ?ws_key=myapikey&display=full

1 Like

thank you!

tried

c.OptionURL =  "https://www."+TxtShopUrl.text.trim+"/api/"+SpTabella.Text.Trim+"/1/"+"/?ws_key="+TxtApiKey.Text.Trim+"&?display=full"

and works! this afternoon I’ll try with more arguments!

after some test, I can say that is not working…

infact, trying with postman (first, before testing in xojo)

https://myshop.com/pshop/api/countries/?ws_key=myapikey/?schema=blank

I don’t get any blank schema

That should look like this:

https://myshop.com/pshop/api/countries/?ws_key=myapikey&schema=blank

Note that an ampersand separates URL parameters, not /?

1 Like

Anthony é corretto. :+1::+1:

1 Like