How to create a Post request , Pass data in body

Hello Friends

I am working on web API, creating a post request

I want to send data in the Body of the post request for the same I have created a text file that contained the data

  • I read the data from the text file name finaltextfile.txt

  • Read text file, and pass that variable in the body ,but its not working

I think I am missing something could you please help me with that

Hey @JSR_Techno_Talk_s

Please mention Body Format as application/json

Thanks
#nK

HI @JSR_Techno_Talk_s

You will need to stringify your JSON data so that you can pass the JSON in body as a string something like below so that you can pass this string the BODY as a string.

“{"clientKey" :"ed234444444444""task":{"type:"ImageToTextTask","body":"rjIUIGWEaX2gk43lJK8dMLPJFijro305mdfopdOP="}”

To easily do this you can use https://jsonformatter.org/json-stringify-online to convert your JSON to String

Hope this helps.

Thanks it solved now

Hello,
i have the same problem:

“body”: {
“mode”: “formdata”,
“formdata”: [
{
“key”: “fichier”,
“description”: “rib”,
“type”: “file”,
“src”: “/C:/Users/xxx/OneDrive - yyyy/Desktop/Colibris +/Robot_zzzz/Data/Output/mmmmmm_text.pdf”
},
{
“key”: “metadonnees”,
“value”: “{\n "numen": "mmmmmm",\n "nature": "conges_et_absences/conge_de_maladie_ordinaire",\n "format": "numerique"\n}”,
“description”: “json”,
“type”: “text”
}
]
}

i had stingfied the body but when passing:

1 Like

Have the JSON in a text file, Read it and use in UiPath!

i have always the following error:

1 Like

Hey @abdel

The error is after sending the request ?

Thanks
#nK

yes
in fact i had uploaded a pdf file in a repository (there is no error when uploading with http request):

End point: http://xxxxxxx/documents/arretes

i need to download this document

when uploading the document using http request:

I had the following response (there is no id generated like in postman):

<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Gravitee.io Portail</title>
    <base href="/" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="icon" type="image/png" href="favicon.png" sizes="96x96" />
    <script src="webcomponents/webcomponents-loader.js"></script>
  <link rel="stylesheet" href="styles.e0626c0f9f0284497b30.css"></head>
  <body>
    <gv-spinner id="loader"></gv-spinner>
    <app-root></app-root>
  <script src="runtime-es2015.33e625c09ce899a4e012.js" type="module"></script><script src="runtime-es5.33e625c09ce899a4e012.js" nomodule defer></script><script src="polyfills-es5.a1e3e93b0d43c59dbb37.js" nomodule defer></script><script src="polyfills-es2015.8ea7045f2d75fc02ed20.js" type="module"></script><script src="scripts.9b9151f02d2cc705805c.js" defer></script><script src="main-es2015.7ef12a4f4b7aa5ae50ea.js" type="module"></script><script src="main-es5.7ef12a4f4b7aa5ae50ea.js" nomodule defer></script></body>
</html>

1 Like

Hey @abdel

So the request is not working.

Kindly first show us how are you performing this on postman please ?

Thanks
#nK

how to passe this json to uipath:

{
			"name": "Créer arrêté",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "ffff-Transaction-Timeout",
						"value": "300",
						"type": "text",
						"disabled": true
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "fichier",
							"description": "rib",
							"type": "file",
							"src": "/C:/Users/.../OneDrive - /Desktop/.../Robot_/Data/Output/191069134534490_ssss.pdf"
						},
						{
							"key": "metadonnees",
							"value": "{\n    \"numen\": \"191069134534490\",\n    \"nature\": \"Mutation-affectation/Mutation_ou_Affectation\",\n    \"format\": \"numerique\"\n}",
							"description": "json",
							"type": "text"
						}
					]
				}

Even though this is json, you need to pass it on a string right ?

Yes that IS it

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.