Skip to main content
treven
Explorer
Aug 4, 2023 4:52 PM UTC
Solved

Fortinet Sandbox API Login Request Error


curl -X POST \
https://1.2.3.4.5/jsonrpc \
-H 'Accept: application/json' \
-H 'cache-control: no-cache' \
-k \
-H 'content-type: application/json' \
-H 'postman-token: 593987-1324' \
-d '{
"method": "exec",
"params": [{
"url": "/sys/login/user/",
"data": [{
"user":"username",
"passwd":"PASS"
}]
}],
"session":"1111111111111",
"id": 1,
"ver": "2.0"
}'

if [[ $? -eq 0 ]]; then
echo "API call successful. Response:"
else
echo "API call failed."

fi

 

I keep receiving an Invalid Request Response "code" 10 in the API response. Does anyone have any suggestions? Some of the other API requests such as the session request work fine so it leads me to believe there is some issue with the given parameters in the request. Any help would be greatly appreciated. Thank you.

spoojary
spoojaryAnswer
Staff
Sep 8, 2023 2:56 PM UTC

If you're getting an "Invalid Request" response:

  1. Verify Endpoint & Method: Check the API documentation to ensure the URL and method are correct.
  2. Headers: Ensure all headers match what's required by the API.
  3. JSON Structure: Confirm there are no structural errors in your JSON payload.
  4. Credentials: Double-check that "user" and "passwd" values are correct.
  5. Session Token: Make sure your session token is still valid.
  6. API Version: Confirm the version ("ver": "2.0") is supported.
  7. Use Tools: Consider using Postman or Insomnia for easier debugging.
  8. Review API Response: Check the full response for specific error hints.

2 replies

spoojary
Staff
spoojaryAnswer
Staff
Sep 8, 2023 2:56 PM UTC

If you're getting an "Invalid Request" response:

  1. Verify Endpoint & Method: Check the API documentation to ensure the URL and method are correct.
  2. Headers: Ensure all headers match what's required by the API.
  3. JSON Structure: Confirm there are no structural errors in your JSON payload.
  4. Credentials: Double-check that "user" and "passwd" values are correct.
  5. Session Token: Make sure your session token is still valid.
  6. API Version: Confirm the version ("ver": "2.0") is supported.
  7. Use Tools: Consider using Postman or Insomnia for easier debugging.
  8. Review API Response: Check the full response for specific error hints.
treven
trevenAuthor
Explorer
Sep 8, 2023 3:11 PM UTC

Thank you for your advice it was indeed a structural error with the JSON parameters just needed to step through it error by error. 

 

Thank you again for all of your suggestions.  

Risk and Resilience in the Age of AI. An OT Thought Leadership Summit for Houston's Critical Infrastructure Leaders. Date: Thursday, December 3, 2026. Time: 8:30 am - 1:30 pm (CT). Location: The Westin Houston, Memorial City | 945 Gessner Road, Houston, TX 77024