Forum Discussion
Anonymous
9 years agoNot applicable
Connect to restful api data source multiple times
Hi, I am a complete Newbie with regards to Resftul services etc, I am trying to connect to a Second Street Api using the below. It seems you need to use a Post first to get an access toke, ho...
- Anonymous9 years ago
FYI we got it connecting using
let apiUrl = "https://api.secondstreetapp.com/sessions", data ="{'sessions':[{'username':'**', 'password': '**'}]}", options = [ Headers =[#"Content-Type"="application/json", #"X-Api-Key"="*****"], Content = Text.ToBinary(data) ], Value = Web.Contents(apiUrl,options), in Value
Anonymous
9 years agoNot applicable
Hi,
We managed to get to conect to the api using PHP but wanting to do it in PowerBi. How would I go about translating
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.secondstreetapp.com/sessions"); //curl_setopt($ch, CURLOPT_URL, "https://www.google.com"); //$data = array("sessions"=>array("username"=>"****", "password"=>"***")); $data = '{"sessions":[{"username":"*****", "password": "*******"}]}'; curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json', 'X-Api-Key: *****')); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE, true); $session = curl_exec($ch); echo curl_error($ch); curl_close($ch); $sessionDecoded = json_decode($session); if ($campaignID == null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.secondstreetapp.com/message_campaigns?statusTypeId=1"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/json', 'X-Api-Key: *****', 'Authorization:'.$sessionDecoded->sessions[0]->access_token, 'X-Organization-Id:'.$sessionDecoded->sessions[0]->organization_id)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE, true); $newsletters = curl_exec($ch); echo curl_error($ch); curl_close($ch); $newslettersDecoded = json_decode($newsletters); echo "<div class='list-group'>"; echo "<h1>Select a message</h1>"; foreach ($newslettersDecoded->message_campaigns as $campaign) { echo "<a href='index.php?campaignid=".$campaign->id."&messagetype=".$campaign->message_campaign_type_id."' class='list-group-item'>".$campaign->name."</a>"; }
Anonymous
9 years agoNot applicable
FYI we got it connecting using
let
apiUrl = "https://api.secondstreetapp.com/sessions",
data ="{'sessions':[{'username':'**', 'password': '**'}]}",
options = [
Headers =[#"Content-Type"="application/json", #"X-Api-Key"="*****"],
Content = Text.ToBinary(data)
],
Value = Web.Contents(apiUrl,options),
in
Value
- Anonymous8 years agoNot applicable
how did you set your credentials? as anonymous?
I have a similar API but it seems it is not accepting my username and password parameters.When I use anonymous, I get error. When I use basic auth (with pop up box), I get error from web.content only possible when anonymous...
- Anonymous8 years agoNot applicable
We ended up going down the PHP route