Excel data table to HTTP request wizard body

Hello guys, I have a question. I constantly get a Excel file with a data table that has headers and information that needs to be imported into a webpage via HTTP request wizard. My question is how and is it even possible?
This is how the excel data looks:


If my thoughts are right, I need to read the data table in excel, then use assign activity to serialize it to Json Object with JsonConvert.SerializeObject(dtTable) and simply pass it to HTTP request wizard’s body? But what about the parameters? Should I do anything there?

Hi,

1.Read excel
2.Convert DataTable to JSON: Use the JsonConvert.SerializeObject method to convert the DataTable into a JSON string.
3. Set up the HTTP Request activity:

  • Configure the necessary URL, method (e.g., POST), and headers in the HTTP Request activity.
  • In the “Body” field of the HTTP Request activity, pass the jsonString variable as the request payload. This will send the JSON data to the webpage.
  1. Handle parameters: If your webpage requires additional parameters or query parameters in the URL, you can configure them in the HTTP Request activity’s “Parameters” section. Add any necessary parameters, such as authentication tokens, API keys, or specific request parameters required by the webpage.
    Make sure to adjust the HTTP Request activity’s settings, such as authentication and timeout, according to the requirements of the webpage you’re interacting with.

Regards.

Hi @Povilas_Jonikas

Parameters are optional.Eventhough you didn’t give the parameters able to work.

  1. Open the HTTP Request Wizard and configure the necessary properties such as URL, method (GET/POST), and headers.
  2. In the “Body” section of the wizard, pass the jsonString variable as the body content. Ensure that the “Body Type” is set to “Raw” and the “Content-Type” header is set to “application/json”.
  3. If your API requires additional parameters, such as query parameters or headers, you can set them in the corresponding sections of the HTTP Request Wizard. For example, if your API requires an API key in the headers, you can add a header parameter with the key-value pair.

Hope it helps!!

Hello,

Ok, so for my understanding all the headers that are in JsonObject variable in Body, needs to be in the parameters? Lets say I have JsonObject with headers: car_id, part_id, part_price - then theese should be in the parameters section?

Hi,

No The jsonobject already have the car_id, part_id, part_price then these should not be in the parameters section

Thank you

Ok, got it. So for now I have it looking like this:


This is the jsonstring:
image
I see that in some of the places it adds a “0”. Why is that?

Ok, the 0 problem is fixed. Wanted to ask another thing. Will this JsonString be good for the Body imput?
image

Hi,

Yes, Try this

Thank you

Yes, I tried it, and got an error like this:
image
Even tho, I have username, password and user_token set in parameters. Is it possible, that the specific API wants username, password and the user_token to be in the body?

I’ve just added 3 extra headers to the Json string, which are username, password, user_token. I can see them in the JsonString that im passing to Body, but still get the same error. Any resolves?

I dont understand. When im running the HTTP request wizard preview it says that I dont have any data passing through (R400). When im running the whole workflow, It gives me the R009, no username found. How could it be possible?

Hi,
Validate that the JSON structure you are passing as the request body in the HTTP Request activity includes the correct key names for the username, password, and user_token. Make sure the keys match the expected header names as defined by the webpage’s API. Additionally, ensure that the JSON structure is well-formed and correctly represents the data.

If it helps, this is how the API from inside looks like:


And the cURL:

curl -X 'POST' \
  'https://api.rrr.lt/crm/importPart' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'rims_spacing=&notes=TESTAS&photos%5B%5D=https%3A%2F%2Fwww.signeda.lt%2Fimage%2Fcatalog%2Fproducts-nw%2Fc_88277.jpg&user_token=******&car_id=637&place=&optional_codes=&position=110&price=500&sell_vat_null=&tires=&rims_quantity=&id_bridge=&english=&photo=https%3A%2F%2Fwww.signeda.lt%2Fimage%2Fcatalog%2Fproducts-nw%2Fc_88277.jpg&tires_width=&status=1&rims_fixing_points=&sticker_note=&username=signeda&rims_central_diameter=&visible_code=testtest3&tires_tread_depth=&sell_date=&manufacturer_code=ZZZZZZZZ2&tires_height=&password=*******&other_code=testtest3&sell_price=&category_id=42&rims=&tires_quantity=&quality=3&original_currency=&internal_notes=TESTUOJAMAS%20API'

Im really thankful for your help, but I still can’t figure it out. The thing is, that I have username, password and user token in parameters and to be safe in the body. Everything looks legit I think, but it still doesn’t work. When I run the workflow, it still keeps giving me the R009 error and I cant even imagine from where is the username missing. Any other help would be much apreciated :slight_smile:

Ok, I think I just found out the reason why I keep getting this error. Is it possible, that it’s because the API only accepts application/x-www-form-urlencoded body format? Does this body format work with the JsonString body that im giving it?

Hi,

https://docs.uipath.com/orchestrator/standalone/2022.10/api-guide/authenticating

Please go through this once.,

1 Like

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