SirLoin699
SirLoin699

Reputation: 13

httpWebRequest Writing Data

I was previously using .NET Core 3.1 and now that I switched to the full, classic .NET Framework 4.7.2, I am getting this issue I can't seem to solve:

var postData = "{\"ChangePrice\":{\"priceInDollars\":" + Price + "}}";
var data = Encoding.ASCII.GetBytes(postData);

using (var stream = httpWebRequest.GetRequestStream())
{
    stream.Write(data); //**The Issue Is here**
}

I keep getting an error

Error CS7036 - There is no argument given that corresponds to the required formal parameter 'offset' of 'Stream.Write(byte[], int, int)"

I've tried a few things but nothing seems to work. I'm sure its one of the issues that has an easy fix and when I see it I'll bonk my head xD

Upvotes: 1

Views: 65

Answers (1)

D. Foley
D. Foley

Reputation: 1024

You're not using the function correctly, look at the documentation microsoft doc.

You need to pass in an offset and a count, like this:

stream.Write(data, 0, 128);

The count however will probably be the length of the byte array, i.e data.Length

Upvotes: 2

Related Questions