8 Replies Latest reply on Aug 8, 2014 8:46 AM by Robb Barrett PRD

    REST API Error code 1006

      We're trying to use the REST API to insert some leads, but we're getting an odd response.

      Request:
      {"action":"createOrUpdate","input":[{"email":"test@abc.com","firstName":"test","postalCode":"11111","company":"Test"}]}
       
      Response:
      {"requestId":"17322#147b213b6cc","success":false,"errors":[{"code":"1006","message":"Field 'Company' not found"}]}

      Even when we take out the "company" line, we get the error about Company not found.


        • Re: REST API Error code 1006
          What do you mean you've taken out the Company line? You've made the call again without that bit in it?
          • Re: REST API Error code 1006
            Robb Barrett PRD
            Yes.  The first time we recevied the error we weren't even sending over Company.
            • Re: REST API Error code 1006
              Hmm. Can you send me the exact request and error where you got that?
              • Re: REST API Error code 1006
                Robb Barrett PRD
                Here's the code our developer is using:

                     var client = new RestClient("https://[REDACTED}.mktorest.com/");
                      
                     var identityRequest = new RestRequest("identity/oauth/token");
                     identityRequest.AddParameter("grant_type", "client_credentials");
                     identityRequest.AddParameter("client_id", @"[REDACTED FOR THIS POST]");
                     identityRequest.AddParameter("client_secret", @"[REDACTED FOR THIS POST]");
                     var identityResponse = client.Execute<AuthResponse>(identityRequest);
                     if (identityResponse.Data != null)
                     {
                         var accessToken = "?access_token=" + identityResponse.Data.access_token;
                      
                         var leads = new Leads
                         {
                             action = "createOrUpdate",
                             input = new List<Lead>()
                             {
                                 new Lead()
                                 {
                                     email = "test@abc.com",
                                     firstName = "test",
                                     postalCode = "11111",
                                     company = "Test"
                                 }
                             }
                         };
                         var leadsRequest = new RestRequest("rest/v1/leads.json" + accessToken, Method.POST);
                         leadsRequest.RequestFormat = DataFormat.Json;
                         leadsRequest.AddBody(leads);
                         var leadsResponse = client.Execute(leadsRequest);
                      
                         //var campaignRequest = new RestRequest("rest/v1/campaigns.json" + accessToken);
                         //campaignRequest.RequestFormat = DataFormat.Json;
                         //var campaignsResponse = client.Execute(campaignRequest);
                     }

                     The response is: 
                     This gives me a server response:
                     {"requestId":"ddb4#147b1e9ab08","success":false,"errors":[{"code":"1006","message":"Field 'Company' not found"}]}

                     PM me if you need the full, uncensored info that I'm using.
                • Re: REST API Error code 1006
                  Robb Barrett PRD
                  P.S. - We added Company to that code to try to solve for this issue.
                  • Re: REST API Error code 1006
                    Robb Barrett PRD
                    Here's the first email our developer sent me:

                    "According to the documentation I should be able to create a new lead by submitting an object like this:
                    {"action":"createOnly","input":[{"email":"test@abc.com","firstName":"test","postalCode":"11111"}]}
                     
                    This gives me a server response:
                    {"requestId":"ddb4#147b1e9ab08","success":false,"errors":[{"code":"1006","message":"Field 'Company' not found"}]}
                     
                    I don’t really know what this ‘Company’ field is and I tried adding an extra field to my request data called Company – that however gives me the exact same error.
                     
                    Also – when trying to call the campaigns endpoint, I get access denied whether I supply a name of a campaign or not.
                    {"requestId":"b335#147b1f0a816","success":false,"errors":[{"code":"603","message":"Access denied"}]}""


                    We solved the Access Denied part by adding to the permissions. You'll need to update the documentation to show that the user role needs ALL the API fields selected, not just "Create Leads" information.
                    • Re: REST API Error code 1006
                      Hey Robb,

                      I think this is a bit involved to do on the community. Have you reached out to support? You've got enough documentation I think they should be able to help you pretty quickly. It's weird this isn't just working so something unique must be going on.
                      • Re: REST API Error code 1006
                        Robb Barrett PRD
                        Thank you. I'll move this to a ticket and post any updates to this thread.