schmorrison / Zoho

Golang API for Zoho services
MIT License
35 stars 34 forks source link

4600: Unable to process your request. Please verify if the name and value is appropriate for the "xmlData" parameter. #2

Closed beatscode closed 6 years ago

beatscode commented 6 years ago

I'm receiving the following error message when trying to insert a new lead:

4600: Unable to process your request. Please verify if the name and value is appropriate for the "xmlData" parameter.

Most likely not the fault of the library but curious if you had any input on the following code.

func TestCRMInsertLead(t *testing.T) {
    apikey := "..."
    // Create a new Zoho object
    z := zoho.New()
    z.SetAuthToken(apikey, "ZohoCRM/crmapi")
    // Create a new CRM object
    c := crm.New(z)
    l := crm.Lead{}
    l.LeadOwner = "a@c.consulting"
    l.Description = "New Registered user"
    l.Fax = ""
    l.Mobile = ""
    l.Website = ""
    l.Industry = "Sales"
    l.NumberOfEmployees = 1
    l.AnnualRevenue = 1800
    l.EmailOptOut = false
    l.SkypeID = ""
    l.Salutation = "Mr."
    l.Street = ""
    l.City = ""
    l.State = ""
    l.ZipCode = ""
    l.Country = "U.S.A"
    l.LeadSource = "a.io"
    l.FullName = "abcFirst abcLast"
    l.Phone = "123-242-1241"
    l.Company = "Blah blah"
    l.FirstName = "abcFirstname"
    l.LastName = "abcLastName"
    l.Email = "abc@aol.com"
    l.Title = "UI Designer"

    leads, err := c.Leads().InsertRecords(crm.InsertRecordsOptions{Data: l})
    if err != nil {
        t.Error(err)
    }
    log.Println(leads)

}
schmorrison commented 6 years ago

Thanks Alex.

I have gotten the same thing. I have been working on it, I think it has to do with the encoding style golang uses for query parameters. Consequently I am making some changes to how request parameters are encoded. (If you want more info about that, let me know.)

I have also proceeded to change the API for accessing fields. (I’ll provide more info about that when it becomes relevant.)

I would suggest waiting to finish writing that test until I push that change. I won’t be tonight, but hopefully I will have made enough progress by Sunday.

On Thu, Feb 22, 2018 at 2:21 PM Alex Casanova notifications@github.com wrote:

I'm receiving the following error message when trying to insert a new lead:

4600: Unable to process your request. Please verify if the name and value is appropriate for the "xmlData" parameter.

Most likely not the fault of the library but curious if you had any input on the following code.

func TestCRMInsertLead(t *testing.T) { apikey := "..." // Create a new Zoho object z := zoho.New() z.SetAuthToken(apikey, "ZohoCRM/crmapi") // Create a new CRM object c := crm.New(z) l := crm.Lead{} l.LeadOwner = "a@c.consulting" l.Description = "New Registered user" l.Fax = "" l.Mobile = "" l.Website = "" l.Industry = "Sales" l.NumberOfEmployees = 1 l.AnnualRevenue = 1800 l.EmailOptOut = false l.SkypeID = "" l.Salutation = "Mr." l.Street = "" l.City = "" l.State = "" l.ZipCode = "" l.Country = "U.S.A" l.LeadSource = "a.io" l.FullName = "abcFirst abcLast" l.Phone = "123-242-1241" l.Company = "Blah blah" l.FirstName = "abcFirstname" l.LastName = "abcLastName" l.Email = "abc@aol.com" l.Title = "UI Designer"

leads, err := c.Leads().InsertRecords(crm.InsertRecordsOptions{Data: l}) if err != nil { t.Error(err) } log.Println(leads)

}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/schmorrison/Zoho/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AQlHI5o66bIjxq3CUxwrsOAgmXb1rsz-ks5tXcxAgaJpZM4SP7Ri .

-- Sam Morrison schmorrison@gmail.com

beatscode commented 6 years ago

Thanks for the update I'll wait for your changes.

schmorrison commented 6 years ago

Hey there.

I was doing some work on it today, but when going to the reference at: Zoho CRM API I saw that they are introducing V2 to the API which seems like a 'purer' REST version, with sane JSON that can be easily parsed with the package in 'encoding/json'. This must have happened in the last week.

The new version is likely much easier to use for implementing a client library. The methods should be looked at closely, but this might change direction of this repo again. Since the old version is now listed as EOL this change is likely inevitable anyway.

If you have any thoughts, let me know.

schmorrison commented 6 years ago

After some looking at V2 of the API, it seems like the obvious course of action, the XML data from V1 is terribly difficult to work with in Go, and in my experience has required the use of reflect in order to parse efficiently.

Changing directions to the new API will mean mapping the new API methods, authentication/scope, and JSON marshalling/unmarshalling. I think making way through the reference top-to-bottom, and implementing things on as 'as-needed' basis.

  1. Managing, obtaining, and refreshing OAuth2 tokens
  2. Authenticated HTTP Requests
  3. API Rate limit headers(nice feature)
  4. HTTP Status Codes and Methods
  5. Request Parameter encoding, and data encoding(much saner, should be a POST body rather than a URL Query Parameter)
  6. Internal data types (eg. Single Line, Multi Line, Pick List, Multi Pick List, Checkbox, Date, Date/Time, Number etc.) should be mapped to corresponding Golang datatypes, and the necessary type conversion to make the value useful in Golang. (This should be automatic with smart JSON encoding/decoding), however might require getting between the JSON response and the Go struct, in order to provided a time.Time rather than a time string a la "2017-08-16T14:32:23+05:30".
  7. Each 'API' group should have probably have a single struct type, (using https://mholt.github.io/json-to-go/ will make that process faster) which represents both the marshall/unmarshall data.

This essentially represents a full rewrite that I will start planning on a branch V2. For the time being I won't continue trying to deal with the original API with project was started for, meaning a pause in development.

If you have any thoughts, or ideas about where to focus, let me know. For me, getting insertRecord to work on the new API is a top priority.