Jump to content

Making external request


Tom S.

Recommended Posts

I'm trying to make an external request using

\IPS\Http\Url::external($somepath)->request()->setHeaders( array('Content-Type' => 'application/json') )->post( array());

So I can set the body and the headers. But How do I set the authorization?  So either CURLOPT_USERPWD or a token?

Link to comment
Share on other sites

$response = \IPS\Http\Url::external( "url" )
	->request()
	->setHeaders( array( 'Content-type' => 'application/json' ) )
	->login( 'username', 'password' )
	->post( array() )
	->decodeJson();
$response = \IPS\Http\Url::external( "url" )
	->request()
	->setHeaders( array( 'Authorization' => "Bearer {$this->token['access_token']}", 'Content-type' => 'application/json' ) )
	->post( array() )
	->decodeJson();

I would really suggest going over our developer documentation - it's all covered there. 🙂

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...