Hi, I'm trying to do an HTTP Post Request. The user guide says I should send this
My code keep timing out. I'm not sure if I'm making the request correctly.
Here's the code [at bottom] I'm trying. Keeping in mind I don't use HTTP request much. I usually do vb.net vb desktop dev.
I've been struggling with this off and on for many hours and would appreciate any help or samples.
Code://line breaks for legibility only POST /ca4f5969-c10f-40d4-8127-e74b691f95de/oauth2/v2.0/token HTTP/1.1 Host: login.microsoftonline.com Content-Type: application/x-www-form-urlencoded client_id=3c29446e-153e-4b92-8f06-c453f117b645 &client_secret=3e04~5e12339444d1852d73bb33e9.3cf2 &grant_type=client_credentials &scope=https://tffproduction.onmicrosoft.com/f06cb173-a8e6-44ad-89a1-06c1070a1f62/.default
Code:Dim uri As String = ("https://login.microsoftonline.com/ca4f5969-c10f-40d4-8127-e74b691f95de/oauth2/v2.0/authorize?") Dim Req As WebRequest = WebRequest.Create(Uri) Req.Headers.Add("client_id", "4e502cbc-a55f-4341-a498-69cfbe19ee7b") Req.Headers.Add("&clientSecret", "Pe48Q~cFymJUFQxw7oTy_eCgQqBUdlG_KifyOcY6") Req.Headers.Add("&grant_type", "client_credentials") Req.Headers.Add("&scope", "https://tffproduction.onmicrosoft.com/f06cb173-a8e6-44ad-89a1-06c1070a1f62/.default") Req.ContentType = ("application/x-www-form-urlencoded") Req.Method = ("POST") Dim response = Req.GetResponse().GetResponseStream() Dim reader As New StreamReader(response) Dim res = reader.ReadToEnd() reader.Close() response.Close()




Reply With Quote
