You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-29 22:27:42 +02:00
91 lines
2.6 KiB
Plaintext
Vendored
91 lines
2.6 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 3
|
|
description: Use body fields at OAuth and other functions to work with HTTP-client in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
|
|
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, HTTP-client]
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
# Use body fields at OAuth
|
|
Includes or excludes body fields when calculating the OAuth signature depending on server requirements
|
|
|
|
|
|
|
|
`Function UseBodyFiledsAtOAuth(Val Flag) Export`
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|-|-|-|-|-|
|
|
| Flag | - | Boolean | ✔ | Flag to use body fields in OAuth signature calculation |
|
|
|
|
|
|
Returns: DataProcessorObject.OPI_HTTPClient - This processor object
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
By default, the body data is used in the signature calculation if it was set using the `SetFormBody` function
|
|
:::
|
|
|
|
:::caution
|
|
**NOCLI:** this method is not available in CLI version
|
|
:::
|
|
<br/>
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
|
URL = "http://localhost:2424";
|
|
URL = URL + "/post";
|
|
|
|
Image = "https://hut.openintegrations.dev/test_data/picture.jpg"; // URL, Path or Binary Data
|
|
|
|
Token = "***";
|
|
Secret = "***";
|
|
UsersKey = "***";
|
|
UsersSecret = "***";
|
|
Version = "1.0";
|
|
|
|
NewRequest = OPI_HTTPRequests.NewRequest().Initialize(URL);
|
|
|
|
Result = NewRequest
|
|
.StartMultipartBody()
|
|
.AddMultipartFormDataFile("file1", "pic.png", Image, "image/png")
|
|
.AddMultipartFormDataField("field1", "Text")
|
|
.AddMultipartFormDataField("field2", "10")
|
|
.UseBodyFiledsAtOAuth(False) // <---
|
|
.AddOauthV1Authorization(Token, Secret, UsersKey, UsersSecret, Version)
|
|
.ProcessRequest("POST")
|
|
.ReturnResponseAsJSONObject();
|
|
```
|
|
|
|
|
|
|
|
|
|
```json title="Result"
|
|
{
|
|
"args": {},
|
|
"data": "",
|
|
"files": {
|
|
"file1": "..."
|
|
},
|
|
"form": {
|
|
"field1": "Text",
|
|
"field2": "10"
|
|
},
|
|
"headers": {
|
|
"Accept": "*/*",
|
|
"Accept-Charset": "utf-8",
|
|
"Accept-Encoding": "gzip",
|
|
"Authorization": "OAuth oauth_consumer_key=\"***\",oauth_token=\"***\",oauth_signature_method=\"HMAC-SHA256\",oauth_timestamp=\"1757978505\",oauth_nonce=\"1757978505\",oauth_version=\"1.0\",oauth_signature=x3IKx5S3ZempwPjMTVyEDtt%2FiAb3vV%2BsGUxGWRz8TOM%3D",
|
|
"Content-Length": "2114372",
|
|
"Content-Type": "multipart/form-data; boundary=9d2c50bb8c0f477ab28e03f975ba4b49",
|
|
"Host": "httpbin.org",
|
|
"User-Agent": "1Script v$2.0.0.0",
|
|
"X-Amzn-Trace-Id": "Root=1-68c8ad99-5a8186776264dc9f5d77c1f2"
|
|
},
|
|
"json": null,
|
|
"origin": "***",
|
|
"url": "https://httpbin.org/post"
|
|
}
|
|
```
|