Hi guys,
I have created a POSTMAN call to WooCommerce, to list all products, that works fine.
I'll put here the real values, as I created them only for this purpose (it's a read only key, I'll disable them as soon as I get this going).
Postman, with Basic Auth, that works (retrieves all products), with no special headers:
GET on URL https://woocriar.com/wp-json/wc/v3/products
consumer key: ck_dc94421352a19885a3fd2e313c5fb8c876b665e1
consumer secret: cs_fa07a3088bbf3b99a2eaae10b809e18e640e3087
Now I'm trying to implement the same thing on PB 2019 R2 (but I'll upgrade to R3 this weekend)
Blob lblb_data
String ls_Base64Str, ls_json, ls_url = 'https://woocriar.com/wp-json/wc/v3/products'
String ls_ck = 'ck_dc94421352a19885a3fd2e313c5fb8c876b665e1'
String ls_cp = 'cs_fa07a3088bbf3b99a2eaae10b809e18e640e3087'
Long ll_ret
RestClient restC
CoderObject lnv_CoderObject
lblb_data = Blob(ls_ck + ',' + ls_cp, EncodingANSI!)
lnv_CoderObject = Create CoderObject
ls_Base64Str = lnv_CoderObject.Base64Encode(lblb_data)
restC = Create RestClient
restC.SetRequestHeader('Authorization', 'Basic ' + ls_Base64Str)
restC.SetRequestHeader('Content-Type', 'application/json; charset=utf-8')
restC.SetRequestHeader('Connection', 'keep-alive')
restC.SetRequestHeader('Accept-Encoding', 'gzip, deflate, br')
restC.SetRequestHeader('Accept-Encoding', '*/*')
ll_ret = restC.SendGetRequest(ls_url, ls_json)
My ll_ret is returning 1, but my ls_json, instead of the products, is returning 401.
{"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources.","data":{"status":401}}
Can you guys point me in the right direction as to get this working? I have many other API calls, but this is my first one using Basic Auth.
Thank you.
Cheers.