Questions by pulling on the Contact of the API fields in bulk

I am putting together a code to export data in bulk using Node.js and I run questions where the call/contact/fields is not valid JSON return.  It seems to occur only when the pageSize gets too high.  It returns the extra spaces or new lines in the JSON that breaks the JSON.parse () function.

The only way I found to work around the problem is to make the size of page 10 or less.  It seems that something bigger and I get a JSON parse error.  Here is the code I am using

function getAllEloquaFields(callback) {
  var https = require('https');
  var config = require('./config'); // This just sets the https options and builds the auth header


  config.options.host = 'secure.eloqua.com';
  config.options.path = '/API/Bulk/1.0/contact/fields?page=100&pageSize=20';
  config.options.port = '443';
  config.options.method = 'GET';

  function final() { callback(results); }

  var page_size = 10;
  var results = [];
  function repeat(page,page_size) {
    config.options.path = url_obj.pathname + 'contact/fields?page='+page+'&pageSize='+page_size;

    var reqGet = https.request(config.options, function(res) {

      res.on('data', function(d) {
        var json;
        try {
          json = JSON.parse(d);
          if(json.elements.length > 0) {
            results = results.concat(json.elements);
            repeat(page+1,page_size);
          } else {
            final();
          }
        } catch(e) {
          console.log('There was an error: ' + e);
        }
      });
    });
    reqGet.end();
    reqGet.on('error', function(e) {
      console.error(e);
    });
  }
  repeat(1,page_size);
};

getAllEloquaFields(url_obj,function(elements) {
  console.log(elements);
});

And here is the article from json which seems to have the problem:

{
      " createdAt": "/Date(-2208970800000)/", //<---- the extra space is messing things up
      "dataType": "string",
      "hasNotNullConstraint": false,
      "hasReadOnlyConstraint": false,
      "hasUniquenessConstraint": false,
      "internalName": "C_SFDCLeadID",
      "name": "SFDC LeadID",
      "statement": "{{Contact.Field(C_SFDCLeadID)}}",
      "updatedAt": "/Date(1270576350780)/",
      "updatedBy": "Some.One",
      "uri": "/contact/field/100024"
},

Anyone else see this issue?

Thank you

Russ

In fact, I solved the problem.  It wasn't the API, I'm new on Node.js and was not manipulate the response correctly.  I was only pulling in one "piece" of data, instead of the complete answer.  The following code is correct.

Thank you

Russ

getAllEloquaFields(url_obj, callback) {
  var https = require('https');
  var config = require('./config');
  config.options.host = 'secure.eloqua.com';
  config.options.port = '443';
  config.options.method = 'GET';

  function final() {
   callback(results);
  }

  var page_size = 100;
  var results = [];
  function repeat(page,page_size) {
    config.options.path = '/API/Bulk/1.0/contact/fields?page='+page+'&pageSize='+page_size;

    var reqGet = https.request(config.options, function(res) {
      var all_data = '';

      res.on('data', function(d) {
        var json;
        try {
          all_data += d.toString();
        } catch(e) {
          console.log('There was an error: ' + e);
        }
      });

      res.on('end', function() {
       //all the data has been sent
       var json = JSON.parse(all_data);
       if(json.elements.length == 0) {
         final();
       } else {
         results = results.concat(json.elements);
         repeat(page+1,page_size);
       }
      });
    });
    reqGet.end();
    reqGet.on('error', function(e) {
    console.error(e);
    });
  }
  repeat(1,page_size);
};

Tags: Marketers

Similar Questions

  • Update of the custom with the API fields

    Hi, (I am currently a place specifically to work on this, so I'd appreciate an urgent response.)

    Unless I missed something - there seems to be no document saying how to upgrade something else than the default fields? I use the RESTful API and could quickly recover contacts. The update Gets a 200 response - but how we update the custom fields?


    Here is a sample code... my guess to send just the name "internal" (line 3) does * not * work.


    $contact-> id = $id;

    $contact-> emailAddress = $lead1 ["emailAddress"];

    $contact->C_Accept_or_Reject_Date1 = time();

    $response = $eloquaRequest-> put ("data/contact /'. ') ($id, $contact);



    Update: I also tried the inner statement without success:

    $contact-> {'{{Contact.Field (C_Accept_or_Reject_Date1)}}"} = time();



    Thanks in advance,

    Sam

    Hi Sam,

    You'll want to see custom fields using their identifier unique and include them as part of a collection fieldValues can only be in your application. See the following example:

    'type': 'Contact,'

    'currentStatus': 'Action pending ',.

    'name': '[email protected]',.

    "accountName": "Eloqua, Inc..

    "address1": "111 Peter Street",

    "country':"Canada. "

    'emailAddress': '[email protected]',.

    'fieldValues can only be':]

    {

    "id': '100021."

    'value': 'value of the custom field.

    },

    ....

    Note that the fieldValues collection can only be contains a record for each custom and its corresponding value field. To search and retrieve the ID unique for your custom fields, you can use the following parameter:

    • GET (list): / assets/contact/fields? Search = {searchTerm} & page = {page} count = {number} & orderBy = {orderBy}

    We also have a post on to access the Contact fields that should help you.

    Please let me know if you need more information.

    Thank you

    Fred

  • How to feed the DFF using the API fields

    Two new fields are need to be added to the employee assignment staging table to support the new design of the approval.

    So two new fields must be filled in HR Oracle using data in the assignment table.

    -> Finance employee id Manager needs to be filled in the FDF (assignment attribute 1)

    -> The agent code must be entered in the FDF (2 attribute assignment).

    How can I fill these two DFFs using an API. I mean how to feed the fields of DFF using the API?

    Use the API-

    hr_assignment_api.update_emp_asg

    Pass the values for the parameters as needed-

    p_ass_attribute1

    p_ass_attribute2

    See you soon,.

    Vignesh

  • Set the signature using the API field only

    I have a situation where all PDFs you signed are created for each customer individually and on the fly.

    I must be able to define the scope of the signature using the API only.

    Is this possible? I can't change the pdf file and add any kind of labels. It must be done using an x, the value of the coordinate y.

    Hello Lawrence,.

    If you are looking to set the fields of the form through the API, you can see below reference material:

    https://secure.NA1.echosign.com/public/docs/EchoSignDocumentService21#FormField

    Kind regards

    -Usman

  • Eloqua Contact Import using the APi REST in bulk does not work.

    Hello

    I'm following the 'EloquaBulkApiDocumentation' of importing contacts in Eloqua using bulk REST API. But I get the error message. I have exactly according to the JSON content that mentioned in the books.

    REMAINS first call - /api/bulk/2.0/contacts/imports/

    {

    "name': 'example of importing Docs."

    'fields': {}

    'C_FirstName': '{{Contact.Field (C_FirstName)}}.

    'C_LastName': '{{Contact.Field (C_LastName)}}.

    'C_EmailAddress': '{{Contact.Field (C_EmailAddress)}}.

    },

    "identifierFieldName": "C_EmailAddress",

    'isSyncTriggeredOnImport': 'false. '

    }

    Second call REMAINS for data:

    {

    'element':]

    {

    "FirstName": "Juan."

    'Name': 'Garcia ',.

    'emailAddress': " " [email protected] "" "

    },

    {

    "FirstName": "Tatiana"

    "Name': 'Smirnov."

    'emailAddress': " " [email protected] "" "

    }

    ]

    }

    Third, called for synchronization:

    17. here is my id of the list I got rest first Call.

    {

    'syncedInstanceUri': ' / contacts/import/17 "»

    }

    Concerning

    Chrystel.

    Here are the details of the journal:

    " < response xmlns =" https://secure.P03.Eloqua.com/API/bulk/2.0/syncs/4/logs ">

    < number > 8 < / count >

    < hasMore > false < / hasMore >

    elements <>

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.0870000Z < / converted >

    < message > managed to convert file 2014-06-23 T 22-30 - 22_User27_2f3ed1c87d33418f91205d7daee640b8.json (0 KB) with json converter. < / message >

    information < gravity > < / gravity >

    < statusCode > ELQ-00104 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1370000Z < / converted >

    < message > field (C_FirstName) is a part of the import definition, but not included in the file. < / message >

    < Gravity > warning < / gravity >

    < statusCode > ELQ-00121 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1370000Z < / converted >

    < message > field (C_LastName) is a part of the import definition, but not included in the file. < / message >

    < Gravity > warning < / gravity >

    < statusCode > ELQ-00121 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1370000Z < / converted >

    < message > identifierFieldName (C_EmailAddress) must be contained in the fields, if specified. < / message >

    error < gravity > < / gravity >

    < statusCode > ELQ-00112 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1370000Z < / converted >

    < message > field (element) is not part of the import definition and will be ignored. < / message >

    < Gravity > warning < / gravity >

    < statusCode > ELQ-00111 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1500000Z < / converted >

    < message > there is no fields mapped into the file 2014-06-23 T 22-30 - 22_User27_2f3ed1c87d33418f91205d7daee640b8.csv. < / message >

    error < gravity > < / gravity >

    < statusCode > ELQ-00127 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1500000Z < / converted >

    < message > there was a processing error import. < / message >

    error < gravity > < / gravity >

    < statusCode > ELQ-00107 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < e >

    < number > 0 < / count >

    < converted > 2014-06-23T 22: 31:25.1370000Z < / converted >

    < message > trying to unlock the file 2014-06-23 T 22-30 - 22_User27_2f3ed1c87d33418f91205d7daee640b8.csv on import for user 27 17. File has been unlocked. < / message >

    < Gravity > warning < / gravity >

    < statusCode > ELQ-00110 < / statusCode >

    < syncUri >/synchronization/26 < / syncUri >

    < /e >

    < / object >

    < deadline > 1000 < / limit >

    < offset > 0 < / offset >

    < > 8 totalResults < / totalResults >

    < / answer >

    Hi all

    I fix the problem by changing the demand for DATA service of rest. It should be like this:

    [

    {

    "FirstName": "Martin",

    'Name': 'Joseph',

    "" "emailAddress": "[email protected]"

    },

    {

    "FirstName": "Sophia"

    'Name': 'Selly ',.

    "" "emailAddress": "[email protected]"

    }

    ]

    Concerning

    Chrystel.

  • Pull on the Notes field

    What would be the best way to shoot just a single word of the section notes.

    Assuming that there are a lot of things in the section notes and I wanted to just get out if he says 'Production '.

    Notes:

    Windows XP

    ABC rental

    Date: 090909

    Owner: scoobydoo

    Status: Production

    I want only the word 'Production' that I can send to another exit.

    I tried split and select-object but I am not having too much luck.

    Something like this should do the trick

    $mask = [regex]"(?Production|QA|Test|Dev)"
    $result = $vm.notes | Select-String -Pattern $mask
    $reportedvm.PatchSched = $result.Matches[0].Groups["status"].Value
    
  • Load pull to the output corresponding to network design

    Hello

    I tried to design the entrance and exit of the matching networks for a power amplifier using the traction load script and the elements of HBTUNER2. According to the contours of traction load, the optimal point impedance is 15.37 - j21.99 (I chose a compromise between EAP, DCRF and PGain). Now my question is when I use the wizard iMatch to convert this to a 50 ohm termination impedance, use 15.37 - j21.99 or the conjugate 15.37 + j21.99? Otherwise, what is the reason? I always thought that load a script pull gave the impedance looking into the port of the active peripheral side. How did the point impedance suggested by loading a script pull to interpret?

    Thank you much in advance.


  • Step in E9 program to write the data of the card field to contact Field?

    Is there a program in E9 step that allows you to write data of a contact card in a field on the contact?

    Question: What is the purpose?

    E9 you can merge the CDO data in emails using mergers to field (E10 is only event field data).  You can trigger the email with the program generator or services data card (use of the services to be added to a program)

    If this isn't the case, have you looked into using the mapping in E9? Since CDO details screen > data card game Menu > field mapping

  • Question of hierarchy for the keyword Lightroom 3

    I use primairly LR3 to follow the architectural photographs with many different style or maintained by keyword type designations.  A hierarchy of keywords can be Tudor > (included under the Tudor) symmetrical > Gabled (included in Tudor).  Often, I'll print contact sheets that include key words displayed in the form of photo information.  On what seems to be a completely random basis print keywords may or may not include the entire hierarchy.

    If I check Gabled include in/under Tudor I can have printed on my board contact Gabled > Tudor or just Gables.  Never is it same rest forever.  Certain keywords, symmetrical say can print as symmetrical > Tudor and always will do.  I can redo the keyword (remove and replace), and it may or may not contain the hierarchy now.

    Random action must be something I am or don't do, but have you tried thousands of times to get a consistent result with no luck.  My library of architecture has more than 126 k photos.  I used LR since the first version beta and been able to resolve or understand recent questions (if Adobe or mine).  This question has me and there appear to be no questions and answers on the subject (probably few people rely on the ability to print a string of keyword).  And Yes, there are several workaround solutions, but not how I should approach.

    Anyone, please?

    LR will only show the hierarchy of keywords if the keyword exists more than once in your list of keywords. If you have one "Gabled" keyword in the list, you will see only "Gabled" in your photo info.

    Marc

  • I want to reset my security questions, but there not the possibility of

    I want to reset my security questions, but there not the possibility of

    Click here > If you forgot your Apple ID - Apple Support security questions answered

  • How can get answers to the question of security of the apple account

    How can I get answers to my account security question?

    See the following link for instructions: If you forgot your Apple ID - Apple Support security questions answered

  • Find my friends pulled from the app store

    So yesterday, there was an update pushed to find my friends and Podcasts. So when I try to update it says "my friends is available on IOS." To get to find my friends, get on the App Store on your iOS device. "(it's on my iTunes on my mac).

    So to speak of Apple Support and they say find them my friends and Podcasts was pulled from the App store inexplicably?

    Anyone know what is happening?

    We are not likely to know more about it than an Apple. A proposal, perhaps apps are updated.

  • Question not answered on the activation of JavaScript

    There was a question and answer on the activation/deactivation of JavaScript using "subject: config.
    Added another question, which I also have another question in response:

    «Despite my Javascript for Firefox 'active' 23 (I checked the ' topic: config "steps above), certain sites are always asking me to activate my Javascript to view content.»

    I am now running NoScript I know blocks JavaScript, but it was going on until I started NoScript.

    I hope someone can answer this question now.

    Thank you
    Bernadine

    This website message can be triggered by other modules or bad script on the Web site that raises this message.

    Try Firefox Safe mode to see if the problem goes away. Safe mode is a troubleshooting mode, which disables most of the modules.

    (If you use it, switch to the default theme).

    • Under Windows, you can open Firefox 4.0 + in Safe Mode holding the key SHIFT key when you open the desktop Firefox or shortcut in the start menu.
    • On Mac, you can open Firefox 4.0 + in Safe Mode holding the key option key when starting Firefox.
    • Under Linux, you can open Firefox 4.0 + with leaving Firefox then go to your Terminal and running Safe Mode: firefox-safe-mode (you may need to specify the installation path of Firefox for example/usr/lib/firefox)
    • Or open the Help menu and click on the restart with the disabled... modules menu item while Firefox is running.

    Once you get the pop-up, simply select "" boot mode safe. "

    If the issue is not present in Firefox Safe Mode, your problem is probably caused by an extension, and you need to understand that one. To do this, please follow article Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems .

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before you open Firefox for normal use again.

    When find you what is causing your problems, please let us know. It might help others who have the same problem.

  • Safari with question marks instead of the text

    Several Web sites in Safari 9.1 showing many points of question marks instead of the text. I just proposed by Apple and done nothing. I have Imac (late 2009) OS X El Capitan 10.11.4.

    Question marks instead of the text is an indication of a problem with fonts.

    Open the book fonts in your Applications folder.

    In the fonts start menu bar click book fonts > Preferences and then click: resolve duplicates by moving the files to the trash

    Quit and then restart Safari to test.

    If this does not help, back to the font book menu bar click file > restore to the Unicode Standard

    Quit and then restart Safari to test.

  • I have a question please. Are the activation of wifi, Bluetooth and 3G while I'm outdoor consume the battery of my iPhone (6 s) and reduce its life expectancy?

    I have a question please. Are the activation of wifi, Bluetooth and 3G while I'm outdoor consume the battery of my iPhone (6 s) and reduce its life expectancy?

    If you want your Apple Watch to stay connected to the phone, you need to keep compatible BlueTooth.

    All functions of the phone will use up the battery life. Some things more than others. Screen brightness, low cell signal strength and location services are major culprits. If you are having battery problems, see this article:

    http://www.scottyloveless.com/blog/2014/the-ultimate-guide-to-solving-iOS-batter y-drain

    I don't know what it means being out of doors has to do with the question.

Maybe you are looking for

  • HP G62t-350: PCi Simple Communications Controller driver

    Hello I just be reformatted my HP G62-350 with the same Windows 7 Home Premium and now I have a driver to the left to find, and it is difficult. It is for the controller PCI of communication Simple. I'll include the hardware ID: PCI\VEN_8086 & DEV_3B

  • AP large-scale deployments... DHCP or static IP address?

    Simple question (s): If you are a big corporate customer that controls devices with HP OpenViiew, you deploy hundreds of wireless AP with DHCP, taking advantage of the ease and convenience DHCP gives you or, statically assign you the AP IP addresses

  • "Important calls" blackBerry smartphones in the profile alert screen

    I was setting up the vibrate profile and I was curious about the option "Use the active profile with the exception of the important calls" - exactly what he defines as an importantcall and how it determines that a call is important? Also - what is a

  • I have new iphone but my computer does not detect this why?

    I have new iphone but my computer does not detect this why?

  • Creating DVD in yet?

    You are using a Mac Book Pro and the latest version of first, I created a file Mpeg-2 to 10 minutes... Adobe Dynamic Link is naturally grayed out, so I opened again and file-> import-> asset import file... it is visible in the project tab, but now I