AnsweredAssumed Answered

Unable to get WooCommerce REST API to cooperate

Question asked by cdunkake on Jan 5, 2018
Latest reply on Jan 6, 2018 by bigtom

I've tried everything (probably not) to connect a FM16 solution with WooCommerce (WordPress).

The Woo documentation is not great but existing: WooCommerce REST API Documentation - WP REST API v2

 

In native FM this should work (as curl settings):

Let ( [

     $H2 = "Content-Type: application/json" ;

     $C1 = $ConsumerKey & ":" & $ConsumerSecret

] ;

     " -X GET" &

     " -u " & Quote ( $C1 ) &

     " -H " & Quote ( $H2 )

)

 

I also tried MBS:

Set Variable [ $curl ; Value: MBS( "CURL.New" ) ]

Set Variable [ $result ; Value: MBS( "CURL.SetOptionURL"; $curl; $url ) ]

Set Variable [ $result ; Value: MBS( "CURL.SetOptionPassword"; $curl; $ConsumerKey ) ]

Set Variable [ $result ; Value: MBS( "CURL.SetOptionUsername"; $curl; $ConsumerSecret ) ]

Set Variable [ $result ; Value: MBS( "CURL.SetOptionVerbose"; $curl; 1 ) ]

Set Field [ LOG_Logs::Note3 ; MBS( "CURL.Perform"; $curl ) ]

Set Field [ LOG_Logs::Note4 ; MBS( "CURL.GetHeaderAsText"; $curl ) ]

Set Variable [ $result ; Value: MBS( "CURL.Cleanup"; $curl ) ]

 

But only get back

HTTP/1.1 401 Unauthorized

Date: Fri, 05 Jan 2018 14:51:42 GMT

Server: Apache

X-Robots-Tag: noindex

Link: <https://photo18.ch/wp-json/>; rel="https://api.w.org/"

X-Content-Type-Options: nosniff

Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages

Access-Control-Allow-Headers: Authorization, Content-Type

X-Powered-By: PleskLin

Transfer-Encoding: chunked

Content-Type: application/json; charset=UTF-8

 

Anyone any idea what's wrong?

Outcomes