Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
msc23
New Contributor II

Sandbox API Login: return values?

i try to login via a python script, after some struggeling with the certificates i get a return code 200.

but when i try to parse the return value it's not a json object (or structure) it's html.

 

login-request and check response:

 

response = requests.post(loginURL, json=login_data)
print(f"response status code : {response.status_code}")
if response.status_code == 200:
print(response.text)
try:
json_data = response.json()
for key in json_data:
print(key)
except ValueError as e:
print("some ERROR raised:")
print(e)

 

and the print of the response ist html:

<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<title>FortiSandbox</title>
<base href="/ng/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<style>@charset "UTF-8";body{font-family:Lato,Helvetica,Arial,sans-serif}body{font-weight:var(--nu-theme-dimension-normal-font-weight)}body{background-color:rgb(var(--nu-theme...................

(and much more, but no values, like a sessionid oder similar)

 

 

any hints where i went wrong?

thanks a lot!

 

1 Solution
ebilcari

According to FNDN documentation the URL seems correct but the password parameter should be changed to passwd

If not joined yet I would strongly suggest you to join the developer network. Two sponsor approvals are needed and your Fortinet local representative can help with that.

- Emirjon
If you have found a solution, please like and accept it to make it easily accessible for others.

View solution in original post

3 REPLIES 3
ebilcari
Staff
Staff

What is the API call in this case? Maybe try with an API client like Postman or curl as a start. I don't have experience with python but based on the result it seems like it's parsing the web page source.

- Emirjon
If you have found a solution, please like and accept it to make it easily accessible for others.
msc23
New Contributor II

sorry, maybe it's a misunderstanding. 

i make an request to a URL 

loginURL = "https://fortisand-api.our-donain.com/"

the login-data (from the FortiSandbox-4.4.3-JSON-API Reference):

login_data = {
"method": "exec",
"params": [
{
# "url": "/sys/login/user",
"user": username,
"password": password
}
],
"id": 1,
"ver": "2.3"

and then getting the response:

response = requests.post(loginURL, json=login_data)

but the response contains only html. 

so how can i get the session-id in this case to make further calls to the fortisandbox?

 

is there an error on the URL?

 

any help is appreciated!

thanks in advance!

ebilcari

According to FNDN documentation the URL seems correct but the password parameter should be changed to passwd

If not joined yet I would strongly suggest you to join the developer network. Two sponsor approvals are needed and your Fortinet local representative can help with that.

- Emirjon
If you have found a solution, please like and accept it to make it easily accessible for others.
Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors