Technical Tip: How to upload an OpenAPI file on FortiWeb using the REST API
Description
This article describes how to upload an OpenAPI File on FortiWeb using the REST API.
Scope
FortiWeb.
Solution
Set Up Postman:
Open Postman and create a new request.
Select the POST method.
Define API URL:
Use the appropriate API endpoint for uploading OpenAPI files. Replace <FWB-IP> and <port> with the FortiWeb IP address and source port.
Example URL: https://<FWB-IP>:<port>/api/v2.0/openapi/upload
Configure Request Body:
Use form-data to upload the OpenAPI file.
Key: file
Value: Select the exact OpenAPI file from the local machine.
Send the Request:
Select Send to upload the file.

The result should look like this:

curl -k -X POST 'https://<fortiweb-ip>:<port>/api/v2.0/waf/openapi.openapischemafile' \
-H 'X-CSRFTOKEN: <csrf-token>' \
-H 'Origin: https://<fortiweb-ip>:<port>' \
-H 'Referer: https://<fortiweb-ip>:<port>/root/waf/openapi/schema-dialog' \
-H 'Cookie: <valid-session-cookie>' \
-F 'openapifile=@openapi.yaml'
Follow the guide below to generate the CURL commands outlined above:
Technical Tip: How to use browsers to obtain curl commands for testing
