-
-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow (json-)strings for Mage_HTTP_Client_Curl::makeRequest $params Parameter #913
allow (json-)strings for Mage_HTTP_Client_Curl::makeRequest $params Parameter #913
Conversation
I have looked at the customized version of Magento 2 and discovered the following adaptation: $this->curlOption(CURLOPT_POSTFIELDS, is_array($params) ? http_build_query($params) : $params); This would solve your problem elegantly and offer the possibility of other types such as XML. $uri = '';
$params = array();
$client = new Mage_HTTP_Client_Curl();
$client->addHeader('content-type', 'application/json');
$client->makeRequest('POST', $uri, json_encode($params)); |
Oh yes, that is better, I'll change the request to make that change instead 👍 |
Per @spinsch just submitted the Magento 2 fix for JSON POST utilized as he indicated:
Great idea to look at the Magento 2 repo first, should have thought of that :-) , and will in the future! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc comment needs to be tuned array|string
But it's a very useful change, had similar challenge with magento EE recently too.
3be8074
Updated! 👍 |
…port json encoded strings
…port json encoded strings
What does everybody think about adding this method to allow the Mage Curl client to do proper POSTs of JSON directly. I know of a few REST apis that require this.
This would allow doing this in code to POST json data directly: