Skip to main content

Hello,

 

I am trying to set up a connection with the API, but both in python and postman the response that I get is an HTML text asking me to sign in and code 200.

In postman I used:

"user_name":"XXXXXX",
"password" :"XXXXX",
"account_id":"XXXX"
 

I also tried to use those parameters in the params tab instead of the Body, but I got the same result.

 

In python, I get the same result in response of the following code:

OWM_endpoint = "https://XXXXXXXXXXX.br/api/v1/login"user = "myuser"PASSWORD = "mypassword"account_id = "myaccount_id"parameters = {    "user_name": user,    "password": urllib.parse.quote_plus(PASSWORD),    "account_id": account_id,}headers = {    "Content-Type": "application/json"}response = requests.post(OWM_endpoint, params=parameters, headers=headers)print(response.text)print(response)

The code returns the same html page asking me to sign in:

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html dir="ltr" class="" lang="en">
<head>
    <title>Sign in to your account</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <link rel="preconnect" href="https://aadcdn.msftauth.net" crossorigin>
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="dns-prefetch" href="//aadcdn.msftauth.net">
<link rel="dns-prefetch" href="//aadcdn.msauth.net">

...

 

 

Am I doing something wrong? Do I have to set up something else before trying to call the endpoint?

 

Thanks in advance,

 

 

Hi ​@eder.fernandes,

Thank you for reaching out!

 

The code ‘200 OK’ indicates that the query was correct and the login was successful so you should be able to run the rest of your queries.

 

However, the reason you’re seeing the results in HTML is because the output is set as HTML rather than JSON.

 

Below is an example of functional login query in Postman:

Since your POST URL already contains the account name, you no longer need to specify the account ID, only the username and password of the API admin account.

 

 

To change the output, simply click on the HTML dropdown and select JSON.

 

 

If you need more help, have further questions, or just want to chat about this topic, please don't hesitate to reach out. 


Hi ​@simonamirza, thanks a lot for the quick reply.

 

I tried to change the output to JSON as you mention, but as soon as I click “Send”, the output changes automatically to HTML. If I change to JSON after clicking “Send”, the color of the text changes, but the content is still the same:

 

 

 

The code 200 indicates that the request was successful, but the response seems to be the login page of microsoft:

<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->

<!DOCTYPE html>

<html dir="ltr" class="" lang="en">

<head>

    <title>Sign in to your account</title>

 

In our environment, to login on the SysAid, we need to login to office first and only after that we are able to login to SysAid with our username and password. Could that be the problem? Is there a way around it?

 

Thanks in advance,


Reply