Sage One API Вставка

Я пытаюсь вставить и сохранить продукт в API SAGE ONE ниже, это мой код, у кого есть идеи. Вот документация https://accounting.sageone.co.za/api/1.1.1/Help/Api/POST-Item-Save

  Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

   Dim data = Encoding.UTF8.GetBytes(TextBox1.Text)

   Dim apikey As String = "{CCCFCF5F-3823-4BB1-BBC3-4FC72203459C}"

   Dim baseUrl As String = "https://accounting.sageone.co.za/api/1.1.1/"

      'Item/Save

   Dim stringurl As String = (Convert.ToString(baseUrl & Convert.ToString("Item/Save?APIKey=")) & apikey)

   Dim myUri As New Uri(stringurl, UriKind.Absolute)

  Dim result_post = SendRequest(myUri, data, "application/json", "Post")

  End Sub

   Private Function SendRequest(uri As Uri, jsonDataBytes As Byte(), contentType As String, method As String) As String

    Dim req As WebRequest = WebRequest.Create(uri)

    Dim userName As String = "james@webbis.co.za"

    Dim password As String = "Tytyty@21"

    req.ContentType = contentType
    req.Method = method
    req.ContentLength = jsonDataBytes.Length
    req.Credentials = New NetworkCredential(userName, password)

    Dim stream = req.GetRequestStream()
    stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
    stream.Close()

    Dim response = req.GetResponse().GetResponseStream()

    Dim reader As New StreamReader(response)
    Dim res = reader.ReadToEnd()
    reader.Close()
    response.Close()

    Return res
   End Function

Вот значение массива JSON для текстового поля 1

{ "Описание": "ppee", "Категория": нулевой, "Кодекс": "с", "Активный" ложь "PriceInclusive": 0,0,"PriceExclusive":4,55,"Physical" ложь "TaxTypeIdSales":0,"TaxTypeSales": нулевая "TaxTypeIdPurchases":0,"TaxTypePurchases": нулевой,"LastCost":0.0,"AverageCost":0,0,"QuantityOnHand":0,0,"HasAttachments": ложные, "единица": нулевая "ItemReportingGroupId_Sales":0,"ItemReportingGroupSales": нулевая,"ItemReportingGroupId_Purchases":0,"ItemReportingGroupPurchases": нулевая,"TextUserField1": нулевая,"TextUserField2": нулевая,"TextUserField3": NULL,"NumericUserField1": 0.0" NumericUserField2 ": 0.0," NumericUserField3 ": 0.0," DateUserField1 ": NULL," DateUserField2 ": NULL," DateUserField3 ": NULL," YesNoUserField1 "ложь" YesNoUserField2 "ложь" YesNoUserField3 "ложь" Modified": нулевой, "MajorIndustryCodeId": 0, "GPPercentage": 0.0, "GPAmount": 0.0, "ItemReportingGroupPurchasesName": NULL, "ItemReportingGroupSalesName": NULL, "ID": 0, "AdditionalItemPrices": нулевая}

0 ответов

Другие вопросы по тегам