I am able to authenticate against the SAGE ONE API and also able to retrieve data from the API however I am now trying to post a simple invoice however keep getting a 422 error. Is there something obvious I am missing?
I have double checked the JSON structure and the values i am providing and are all valid. Not sure what i am doing wrong here!
my JSON package looks like this
{"contact_id":"66b76fa19edc11e797950a57719b2edb",
"date":"2019-04-13",
"invoice_lines":[{"description":"Test Description",
"ledger_account_id":"0367afd89ece11e797950a57719b2edb","quantity":1,"unit_price":100}]}
code
Dim http As HttpWebRequest = WebRequest.Create(New Uri("https://api.columbus.sage.com/uki/sageone/accounts/v3/sales_invoices"))
http.Method = "POST"
http.ContentType = "application/json"
http.Accept = "application/json"
http.Headers.Add("X-Site", "mysite")
http.Headers.Add("ocp-apim-subscription-key", "mykey")
http.Headers.Add("Authorization", "Bearer " mytoken)
Dim data = Encoding.UTF8.GetBytes(json)
http.ContentLength = data.Length
Dim stream = http.GetRequestStream()
stream.Write(data, 0, data.Length)
stream.Close()
Dim response = http.GetResponse().GetResponseStream()