0

Python code to c# .net for HTTP Post to API

response = requests.post(auth_url, auth=('apitoken', api_token), data={'grant_type': 'client_credentials'})

response.raise_for_status()

access_token = response.json()['access_token']

auth_header = 'Bearer ' + access_token

header = {'Authorization': auth_header}

Venu immadi
  • 1,585
  • 11
  • 20
  • Feel free to tag me (@john) if this doesn't answer your question. – ProgrammingLlama Jun 13 '19 at 01:44
  • @John can please let me know to access this peace of code access_token = response.json()['access_token'] – Venu immadi Jun 13 '19 at 01:48
  • I recommend the `Newtonsoft.Json` library for that. See [this example](https://stackoverflow.com/a/41239713/3181933). Specific to your question, the code might look like `dynamic parsedResponse = JObject.Parse(responseString); var accessToken = parsedResponse.access_token;`. Not that you should typically deserialize to C# objects, rather than dynamic, though I think in this case it's probably OK :) – ProgrammingLlama Jun 13 '19 at 01:50

0 Answers0