SendCustomRequest Method

Sends a custom request to the Backblaze B2 API.

Syntax

int SendCustomRequest(const QString& qsHttpMethod, const QString& qsOperation, const QString& qsRequestBody);

Remarks

This method can be used to send arbitrary requests to the Backblaze B2 API.

Valid values for HttpMethod are:

  • GET (default if empty)
  • HEAD
  • POST

The value passed for Operation must be one of the API operations described in the Backblaze B2 REST API documentation (e.g., b2_list_buckets).

Usage

When this method is called, the class does the following:

  1. Builds a request URL, including query parameters, as follows:
    • The specified Operation is appended to the base Backblaze B2 API URL (refer to the APIURL configuration setting for more information).
    • All query parameters in the QueryParam* properties are added to the request URL.
  2. Sends the request using the specified HttpMethod, the request URL built in step 1, the header information built from AccountAuthToken and OtherHeaders, and the given RequestBody (if non-empty).
  3. Stores the response headers in the ParsedHeader* properties, and the response body in the specified LocalFile, or ResourceData (using the same logic as DownloadFile).

If the response body is JSON data, the XPath, XText, and other X* configuration settings can then be used to navigate and extract information from it.

Error Handling

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Qt Edition - Version 20.0 [Build 8265]