HTTP Request - Sending text/plain into body

Hi, I have a problem.

My client wants to receive a text/plain with uipath. Here is the example into postman:
image

The problem is that I don’t know where to put it into HTTP Request Properties. It is always giving me an error:

“HTTP Status 400 - Required request part ‘keyName’ is not present”

I’ve put it like an argument in parameters property, urlSegment property, Headers property, Cookies property and also in body property as a variable with the same name ‘keyName’

I don’t know how to send it :frowning:

Can you help me please?

Have you tried sending it in the Attachments @KevinDS

image

Hi @HareeshMR

Yes, it doesn’t work there because it’s a text and whe it is in attachments the HTTP Request is trying to locate a file based in that text so it cause an error.

Is it working when you send the request in postman? @KevinDS

if yes, How you send the file in postman?

Hi @HareeshMR the big problem really is that I’m trying to send not just text/plain variable. I’m algo sending a file in the same webservice.

My Content-Type is multipart/form-data with a boundary (the uipath read this correctly)

Im sending the file in attachments (the uipath read this correctly)

Im trying to put the text/plain in parameters like this:
Variable--------------Type--------------Value
keyName------------String-------“Example Test”

Then, When I run it, uipath needs todo send me a status code 200 Wich it’s a correct response and also it needs to send the file and the string “Example Test” But it’s sending me an exception instead telling me that cannot found ‘keyName’ in the parameters to send

I think I need to write something more into the value maybe to connect with the boundary but I dont know-how how to put it… Or maybe importante doing Something wrong

Can you please explain why you are passing this parameter? @KevinDS

Yes. The client method receive 2 parameters: a multipart file and a string. Im sending the multipart file into attachments and the string into parameters.


The code of the method start like this:

@RequestMapping(value = “/MethodGetData”, method = RequestMethod. POST , consumes = {“multipart/mixed”, “multipart/form-data”}, produces=“applcation/json”)

@ResponseBody

public void MethodGetData(@RequestPart(“keyName”) String keyName, @RequestPart(“file”) MultipartFile file)


So I need to send in the request one ‘file’ parameter (wich is the attachment) and one string parameter (which is keyname)

Please try sending the content type header as application/txt; charset=utf-8 and the request parameter in the request is case sensitive, I hope you are sending the request correctly @KevinDS. And if it is a optional parameter in the request, please ignore sending it.

Hi @HareeshMR , Knowing the method needs to receive one file and one string and I can have just one variable Content-Type how can I put application/text and multipart/form-data in the same value?

yes, you can send parameters seperated with colon ( ; ) @KevinDS . Try it

Hi @HareeshMR, It’s not working. I’m having just Content-Type into Headers, Maybee I need to send something more into header?

The file is in Attachments
The String is in parameters

Can you please post the screenshot of the error @KevinDS?

Try it in postman so that we can get the error easily and we can rectify easily

Hi,

The parameter field is different from the others. Does it require me to fill it in someway else than normal? I can’t seem to get any effect.
image

Can you post what you mean by Parameter here? I think, you are asking about the body type @HenrikX Can you please confirm?

Yes but this may be the problem. I read that it’s advisable to change “Content-Type” but Body format was the closest I could find. Maybe I should have changed Content type somewhere else?

You need to pass the content type parameter as header which is mandatory for some services (based on the developer). So try passing it as a header and check if that is working.

hi all,

is this issue already solve? i got similar issue to…
my API third party only accept form data when post documents. i already tried:

  1. no input “multipart/form-data” content type in header and use attachment properties with correct path file. but my third party respond, “no attachment detected”. i always tried to test path file to prove that the path is correct, and i get same result file opened
  2. with input “multipart/form-data” content type in header, and also input boundary and use attachment properties. i get response to my api "required file parameter ‘file’ ", i tried to put ‘file’ in header, body, parameter etc, but it didn’t work

please let me know how to solve this problem. thank you

Can you please let me know if that is working fine in Postman? @Jefri_Hajrianda