4

In magento 2.4.5, I use some function below to connect with QBO sandbox ZendClient and it's working perfectly:

  • setUri()
  • setConfig(array())
  • setHeaders()
  • setRawData()
  • request($method) ($method can be GET, POST,...)

In magento 2.4.6, ZendClient is replacement by LaminasClient. I have try function from new class LaminasClient:

  • setUri() => setUri()
  • setConfig(array()) => setOptions(array())
  • setHeaders() => setHeaders()
  • setRawData() => setRawBody()
  • request($method) => send()

But the response have status code is 401. I have try debug into function send() and get $uri, $header to test in postman and postman return correctly information of sandbox QBO. I don't know why this happen. Can anyone give me some advices? Thanks.

1 Answer 1

8

I have try replacement ZendClient with class Laminas\Http\Client and it working. This would help me compatible module with Magento version 2.4.6 and the old version 2.4.x can use it too.

Some change function:

  • setUri() => setUri()
  • setConfig(array()) => setOptions(array())
  • setHeaders() => setHeaders()
  • setRawData() => setRawBody()
  • request($method) => send() (before use send(), you need set method with function setMethod($method) first.

Hope this answer could help someone.

1
  • 2
    Also note, in response, isSuccessful() changed to isSuccess() and getStatus() changed to getStatusCode(). Please refer classes located at vendor/laminas/laminas-http/src
    – Deeps
    Jun 12, 2023 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.