-1

I programmed to a Webservice-application with VS2015 and C# a testing tool in which i'm adding files to a HTTP request according to this posting from the forum.

Now i had the problem that i wanted to add json files to the request and later reading the content of these posted files.

I'm adding the file to the request by the following call:

RequestHelper.AddFileToRequest(httpRequest, jsonFileName, "json", new byte[] { 1, 2, 3, 4, 5 });

When i read the content of the posted file in the HTTPPost-method which was called by URL with parameters, i get just the given five bytes.

What have i to do, to add the content of the files correctly to the request?

Patrick Pirzer
  • 1,649
  • 3
  • 22
  • 49

1 Answers1

-1

To do that i had to change the code of the solution from the posting a little bit.

Instead of

RequestHelper.AddFileToRequest(httpRequest, jsonFileName, "json", new byte[] { 1, 2, 3, 4, 5 });

i used

byte[] jsonBytes = File.ReadAllBytes(jsonFileName);
RequestHelper.AddFileToRequest(httpRequest, jsonFileName, "json", jsonBytes);

So i was able to read the content of the posted json file correctly.

Patrick Pirzer
  • 1,649
  • 3
  • 22
  • 49
  • 1
    Downvoting for: If you come here asking a question "3 minutes ago" and immediately answering it, by immediately i mean the same "3 minutes ago", is like creating fake questions to answer your own questions in order to get more reps tbh... If you found the answer the second you posted the question, you should delete the question... Append answers to your own questions when you had to look and try stuff etc, and 5 hours passed or a day or something...imho – MKougiouris Jul 11 '18 at 09:33