Table of contents
Forms

Export

Download API definition:

GET https://api.bentley.com/forms/storageExport?ids[&includeHeader][&fileType][&folderId]

Requests that anywhere from 1 to 5 forms be exported to a file and saved in cloud-based project storage (accessible through the Storage API). Currently 'pdf' is the only supported file type. The IDs of the forms must be specified in a query string parameter named "ids", separated by commas if there is more than one. A sample request URL that exports 3 forms to a PDF is as follows--

https://api.bentley.com/forms/exportPdfToStorage?fileType=pdf&ids=abab23524535,89458jjlij,32636wtewtwt&folderId=090909877987&includeHeader=true

Note that unlike most GET requests, this is not an idempotent operation; each time it is called, a new file will be generated. The response will not contain the file itself, but links to download it from Storage.

All forms specified in the request must come from the same project, or the request will fail. The client may also specify the ID of a destination folder where the file should be saved; otherwise, it will be saved in the project's root folder. They can also specify whether to include a textual header with form metadata at the top of each page (default) or exclude it.

Authentication

Requires Authorization header with valid Bearer token for scope forms:read.

For more documentation on authorization and how to get access token visit OAUTH2 Authorization page.

Request parameters

Name
In
Required?
Description
ids
query
Yes

Instance IDs of forms to export. Must include at least 1, but no more than 5, IDs, separated by commas, and they all must come from the same project.

includeHeader
query
No

If exporting to PDF, indicates whether to include metadata on top of each page. Default is true.

fileType
query
No

Indicates the type of file to create. Right now PDF is the only valid option, and is the default if not specified.

folderId
query
No

The ID, as retrieved from the Storage API, of the folder where the produced file should be saved. If not set, will default to the project's root folder.

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with scope forms:read

Accept
No

Setting to application/vnd.bentley.itwin-platform.v1+json is recommended.

Response 200 OK

Indicates that the file was generated successfully. The response includes the generated file's filename as well as links for using the Storage API to retrieve it.

json
{
    "file": {
        "fileName": "Generated_20220313_1234554321",
        "_links": {
            "destinationFolder": {
                "href": "https://api.bentley.com/storage/folders/ab12cd34ef56gh78"
            },
            "fileMetadata": {
                "href": "https://api.bentley.com/storage/files/zy09xw87vu65ts43"
            },
            "fileDownload": {
                "href": "https://api.bentley.com/storage/files/zy09xw87vu65ts43/download"
            }
        }
    }
}

Response 401 Unauthorized

This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.

json
{
    "error": {
        "code": "HeaderNotFound",
        "message": "Header Authorization was not found in the request. Access denied."
    }
}

Response 404 Not Found

Either one of the forms specified does not exist (code = 'FormDataNotFound') or the destination folder does not exist (code = 'FolderNotFound').

json
{
    "error": {
        "code": "FolderNotFound",
        "message": "Requested folder is not available."
    }
}

Response 422 Unprocessable Entity

This response indicates that there is a problem with the request parameters. Depending on the problem, the 'details' array may include specific errors.

json
{
    "error": {
        "code": "InvalidExportRequest",
        "message": "One or more parameters in the query string are invalid. See 'details' property for specifics.",
        "details": [{
                "code": "InvalidValue",
                "message": "The 'includeHeader' property is of an incorrect type. Expected boolean.",
                "target": "includeHeader"
            },
            {
                "code": "InvalidValue",
                "message": "The IDs 'a' and 'b' come from different projects. All items included together in a PDF must come from the same project.",
                "target": "ids"
            },
            {
                "code": "InvalidValue",
                "message": "The 'folderId' parameter is not a valid ID.",
                "target": "folderId"
            }
        ]
    }
}

Response 429 Too many requests

This response indicates that the user has sent too many requests in a given amount of time.

json
{
    "error": {
        "code": "TooManyRequests",
        "message": "More requests were received than the subscription rate-limit allows."
    }
}

Response headers

Name
Description
retry-after

The number of requests exceeds the rate-limit for the client subscription.

Export Form to Storage (response) Entity

TableSchema
Name
Type
Description
fileName
String

The name of the exported file. (If multiple files were generated for this request, each beyond the first will start with the same name, but with a number in parentheses added just before the file extension.)

Export Form to Storage Links

Links to view the folder where the file was placed, view the file metadata, or download the file contents. The fileMetadata link can also be used to delete the file.

TableSchema
Name
Type
Description
fileDownload
destinationFolder
fileMetadata

link

TableSchema
Name
Type
Description
href
String

Error Response

Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

TableSchema
Name
Type
Description
error.code
String

Short string indicating the general category of error that occurred, such as '{Resource}NotFound'.

error.message
String

Longer string explaining to developers why the error occurred.

error.target
String,null

If relevant, this is the name of the property, URL template parameter, or query parameter that caused the error.

Detailed error-response

Indicates that a request failed and provides a list of details, explaining which properties or parameters in the request were incorrect. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

TableSchema
Name
Type
Description
error.code
String

Short string indicating the general category of error that occurred, such as 'Invalid{resource}Request'.

error.message
String

Longer string explaining to developers why the error occurred.

error.details
Object[]

If relevant, this is the name of the property, URL template parameter, or query parameter that caused the error.

Error

Contains error information and an optional array of more specific errors.

TableSchema
Name
Type
Description
code
String

One of a server-defined set of error codes.

message
String

A human-readable representation of the error.

target
String

The target of the error.

details

Optional array of more specific errors.

Error Details

Contains error information.

TableSchema
Name
Type
Description
code
String

One of a server-defined set of error codes.

message
String

A human-readable representation of the error.

target
String

The target of the error.

Error Response

Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

TableSchema
Name
Type
Description
error

Error information.