Eugene.Wolff Posted February 6, 2014 Share Posted February 6, 2014 Hi Guys, I urgently need some help with this. When I AddClient using the API all works well, including the custom fields. WHen I update, I cannot update the custom fields but I was told that I have to base64 encode the array. I have tried the following without success, the custom fields do not get updated. I am coding in VB.net but c# solutions will work too. Here is my current code, I have included all the commented bit because this is what I have also tried Dim form As New NameValueCollection() form.Add("username", username) ' the password will still need encoding is MD5 is a requirement form.Add("password", Password) ' pass the action for the api to perform form.Add("action", "updateclient") form.Add("clientid", txtUserID.Text) ' action performed by the API:Functions form.Add("address2", "New Test 2") 'form.Add("customfield[5]", "SME") 'form.Add("customfield[13]", "12344512225") 'form.Add("customfield[7]", "999999999") 'form.Add("customfield[8]", "999999") 'form.Add("customfield[9]", "") 'form.Add("customfield[10]", "999") 'form.Add("customfield[14]", "Hardware") 'form.Add("customfield[15]", "Geek Two") Dim CustomFields As New NameValueCollection CustomFields.Add("4", "EFT") CustomFields.Add("5", "SME") Dim bf As New BinaryFormatter Dim ms As New MemoryStream() bf.Serialize(ms, CustomFields) Dim data64 As Byte() data64 = ms.GetBuffer Dim encodeddata As String = String.Format("{0}:{1}", data64.Length, Convert.ToBase64String(data64, 0, data64.Length, Base64FormattingOptions.None)) form.Add("customfields", encodeddata) 'Dim customfields(,) As String = {{"4", "EFT"}, {"5", "SME"}} 'Dim customfields As New Dictionary(Of String, String) 'customfields.Add("4", "EFT") 'customfields.Add("5", "SME") ''form.Add("customfields", customfields) 'form.Add("customfields", Convert.ToBase64String(data64)) Dim responseData As [byte]() = WHMCSclient.UploadValues(cboServer.Text, form) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.