In my windows form project, I’m trying to implement a button that processes data through an API when pressed. I’m running into code 403 object not initialized and I’m not sure what I’m missing. The jsondata and URL work in postman with no errors. Heres my code:
string wono = "00000"+textBox3.Text;
int deptNumber = 1;
string transferQty = textBox2.Text;
int toDeptNumber = 2;
string jsonData = $""WoNo": "{wono}",rn"fromDeptNumber": "{deptNumber}",rn"toDeptNumber": "{toDeptNumber}",rn"transferQty": "{transferQty}"";
string apiurl = "http://myurl";
using (WebClient client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/json";
string response = client.UploadString(apiurl, "POST", jsonData);
MessageBox.Show(response);
}