Magento 2: Calling Restful Web service GET and POSTMagento2 : Restful Web service Calls - controller is not...

Giving a career talk in my old university, how prominently should I tell students my salary?

Should I take out a loan for a friend to invest on my behalf?

Does "Until when" sound natural for native speakers?

Can we track matter through time by looking at different depths in space?

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

Haman going to the second feast dirty

How do spaceships determine each other's mass in space?

Why restrict private health insurance?

Outlet with 3 sets of wires

School performs periodic password audits. Is my password compromised?

Does the US political system, in principle, allow for a no-party system?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

Which situations would cause a company to ground or recall a aircraft series?

From an axiomatic set theoric approach why can we take uncountable unions?

I reported the illegal activity of my boss to his boss. My boss found out. Now I am being punished. What should I do?

Conservation of Mass and Energy

Vocabulary for giving just numbers, not a full answer

When a wind turbine does not produce enough electricity how does the power company compensate for the loss?

Whose blood did Carol Danver's receive, Mar-vell's or Yon-Rogg's in the movie?

Drawing close together horizontal lines in Latex

Professor forcing me to attend a conference, I can't afford even with 50% funding

Why is there an extra space when I type "ls" in the Desktop directory?

How can I get players to focus on the story aspect of D&D?

Is this Paypal Github SDK reference really a dangerous site?



Magento 2: Calling Restful Web service GET and POST


Magento2 : Restful Web service Calls - controller is not showingHow to clear the cache by Magento Web ServiceMagento Web Service - Custom APIExporting products data from one Magento shop to another using web serviceWeb service API SOAP v1 using java for connect?Sending order XML to web serviceCall web service from javascriptMagento2: How to consume web service Get Post MethodsMagento2 : Restful Web service Calls - controller is not showingMagento2: Web service Get method not able to Call properlyMagento2: Web service Call POST method













1















Any one knows how to call restful web service from Magento 2?



Please guide me with a format how it can be done.



Any links to guide me with examples of POST or GET etc.



I want to Call below URL in Magento, Please suggest me structure of module




http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo




This URL results with following Data:



{
status: {
message: "the daily limit of 30000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application.",
value: 18,
}
}


Do I have to create a module? if not where I need to Call this URL?



Thanks in Advance!










share|improve this question

























  • check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

    – lalit mohan
    May 16 '18 at 9:08


















1















Any one knows how to call restful web service from Magento 2?



Please guide me with a format how it can be done.



Any links to guide me with examples of POST or GET etc.



I want to Call below URL in Magento, Please suggest me structure of module




http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo




This URL results with following Data:



{
status: {
message: "the daily limit of 30000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application.",
value: 18,
}
}


Do I have to create a module? if not where I need to Call this URL?



Thanks in Advance!










share|improve this question

























  • check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

    – lalit mohan
    May 16 '18 at 9:08
















1












1








1


2






Any one knows how to call restful web service from Magento 2?



Please guide me with a format how it can be done.



Any links to guide me with examples of POST or GET etc.



I want to Call below URL in Magento, Please suggest me structure of module




http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo




This URL results with following Data:



{
status: {
message: "the daily limit of 30000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application.",
value: 18,
}
}


Do I have to create a module? if not where I need to Call this URL?



Thanks in Advance!










share|improve this question
















Any one knows how to call restful web service from Magento 2?



Please guide me with a format how it can be done.



Any links to guide me with examples of POST or GET etc.



I want to Call below URL in Magento, Please suggest me structure of module




http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo




This URL results with following Data:



{
status: {
message: "the daily limit of 30000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application.",
value: 18,
}
}


Do I have to create a module? if not where I need to Call this URL?



Thanks in Advance!







magento2 module cron rest-api web-services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 7 mins ago









magefms

1,264221




1,264221










asked May 16 '18 at 9:00









JB PakalapatiJB Pakalapati

480216




480216













  • check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

    – lalit mohan
    May 16 '18 at 9:08





















  • check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

    – lalit mohan
    May 16 '18 at 9:08



















check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

– lalit mohan
May 16 '18 at 9:08







check it devdocs.magento.com/guides/v2.1/get-started/rest_front.html

– lalit mohan
May 16 '18 at 9:08












1 Answer
1






active

oldest

votes


















1














You can create a custom module and use curl in your controller action to call this URL and Fetch response body



Curl Example (Sharing the required fragments of the file)



use MagentoFrameworkHTTPClientCurl;
class Curlex extends AbstractHelper {
/**
* @var MagentoFrameworkHTTPClientCurl
*/
protected $_curl;

public function __construct(Curl $curl)
{

$this->_curl =$curl;
}
/**
* Send SMS
* @param type $mobile_no
* @param type $body
*/
public function getResponse($url)
{
$url = urlencode($url);
$this->_curl->get($url);
$response = $this->_curl->getBody();

return $response
}

}


the above example is for GET you can use for similar way (Guide for Curl with post data)






share|improve this answer
























  • I have followed your example, but it says page is not found. can u check this question

    – JB Pakalapati
    May 27 '18 at 6:06











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f226214%2fmagento-2-calling-restful-web-service-get-and-post%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can create a custom module and use curl in your controller action to call this URL and Fetch response body



Curl Example (Sharing the required fragments of the file)



use MagentoFrameworkHTTPClientCurl;
class Curlex extends AbstractHelper {
/**
* @var MagentoFrameworkHTTPClientCurl
*/
protected $_curl;

public function __construct(Curl $curl)
{

$this->_curl =$curl;
}
/**
* Send SMS
* @param type $mobile_no
* @param type $body
*/
public function getResponse($url)
{
$url = urlencode($url);
$this->_curl->get($url);
$response = $this->_curl->getBody();

return $response
}

}


the above example is for GET you can use for similar way (Guide for Curl with post data)






share|improve this answer
























  • I have followed your example, but it says page is not found. can u check this question

    – JB Pakalapati
    May 27 '18 at 6:06
















1














You can create a custom module and use curl in your controller action to call this URL and Fetch response body



Curl Example (Sharing the required fragments of the file)



use MagentoFrameworkHTTPClientCurl;
class Curlex extends AbstractHelper {
/**
* @var MagentoFrameworkHTTPClientCurl
*/
protected $_curl;

public function __construct(Curl $curl)
{

$this->_curl =$curl;
}
/**
* Send SMS
* @param type $mobile_no
* @param type $body
*/
public function getResponse($url)
{
$url = urlencode($url);
$this->_curl->get($url);
$response = $this->_curl->getBody();

return $response
}

}


the above example is for GET you can use for similar way (Guide for Curl with post data)






share|improve this answer
























  • I have followed your example, but it says page is not found. can u check this question

    – JB Pakalapati
    May 27 '18 at 6:06














1












1








1







You can create a custom module and use curl in your controller action to call this URL and Fetch response body



Curl Example (Sharing the required fragments of the file)



use MagentoFrameworkHTTPClientCurl;
class Curlex extends AbstractHelper {
/**
* @var MagentoFrameworkHTTPClientCurl
*/
protected $_curl;

public function __construct(Curl $curl)
{

$this->_curl =$curl;
}
/**
* Send SMS
* @param type $mobile_no
* @param type $body
*/
public function getResponse($url)
{
$url = urlencode($url);
$this->_curl->get($url);
$response = $this->_curl->getBody();

return $response
}

}


the above example is for GET you can use for similar way (Guide for Curl with post data)






share|improve this answer













You can create a custom module and use curl in your controller action to call this URL and Fetch response body



Curl Example (Sharing the required fragments of the file)



use MagentoFrameworkHTTPClientCurl;
class Curlex extends AbstractHelper {
/**
* @var MagentoFrameworkHTTPClientCurl
*/
protected $_curl;

public function __construct(Curl $curl)
{

$this->_curl =$curl;
}
/**
* Send SMS
* @param type $mobile_no
* @param type $body
*/
public function getResponse($url)
{
$url = urlencode($url);
$this->_curl->get($url);
$response = $this->_curl->getBody();

return $response
}

}


the above example is for GET you can use for similar way (Guide for Curl with post data)







share|improve this answer












share|improve this answer



share|improve this answer










answered May 16 '18 at 9:17









Vishwas BhatnagarVishwas Bhatnagar

2,85022045




2,85022045













  • I have followed your example, but it says page is not found. can u check this question

    – JB Pakalapati
    May 27 '18 at 6:06



















  • I have followed your example, but it says page is not found. can u check this question

    – JB Pakalapati
    May 27 '18 at 6:06

















I have followed your example, but it says page is not found. can u check this question

– JB Pakalapati
May 27 '18 at 6:06





I have followed your example, but it says page is not found. can u check this question

– JB Pakalapati
May 27 '18 at 6:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f226214%2fmagento-2-calling-restful-web-service-get-and-post%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

“%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

夢乃愛華...