I successfully pulled leads ID from 1 to 99900. However, the same API call does not work for leads ID larger than 99900. Below is the code that I used to pull leads from the Rest API.
require 'rest_client'
require 'json'
marketo_instance = my_marketo_instance
endpoint = "/rest/v1/leads.json"
#Replace with your access token
auth_token = "?access_token=" + my_token
#Replace with filter type and values
for x in (333..647)
initial_num = x*300+1
final_num = 300*(x+1)
ids_needed = (initial_num..final_num).to_a.join(",")
filter_type_and_values = "&filterType=Id&filterValues=" + ids_needed
fields = "&fields=SFGA%5F%5FCorrelationID%5F%5Fc,SFGA%5F%5FCorrelation%5FData%5F%5Fc,SFGA%5F%5FWeb%5FSource%5F%5Fc,Company%5FType%5F%5Fc,Job%5FFunction%5F%5Fc,LinkedIn%5FProfile%5F%5Fc,Personal%5FTwitter%5F%5Fc,Corporate%5FTwitter%5F%5Fc,Company%5FTicker%5F%5Fc,Email%5FType%5F%5Fc,bit%5Fly%5Fusername%5F%5Fc,Dashboard%5FDomain%5F%5Fc,short%5FURL%5F%5Fc,Timestamp%5F%5Fc,Extention%5F%5Fc,Source%5FType%5F%5Fc,HubSpot%5FInc%5F%5FHubSpot%5FIntelligence%5F%5Fc,HubSpot%5FInc%5F%5FNumberofLocations%5F%5Fc,HubSpot%5FInc%5F%5FSICCode%5F%5Fc,HS%5FINT%5FAdWords%5F%5Fc,Notes%5FAbout%5FNew%5FLead%5F%5Fc,HS%5FINT%5FKeyword%5F%5Fc,Lead%5FConverted%5FDate%5F%5Fc,Lead%5FCreate%5FDate%5F%5Fc,Lead%5FCreate%5Fto%5FConvert%5F%5Fc,Converted%5FMonth%5F%5Fc,hubspot%5Fassigned%5Flead%5Fstatus%5F%5Fc,Hubspot%5FUsesBItly%5F%5Fc,Hubspot%5FScore%5F2%5F%5Fc,Hubspot%5FJob%5FFunction%5F%5Fc,Hubspot%5FCompany%5FSize%5F%5Fc,Hubspot%5FIndustry%5F%5Fc,Hubspot%5FSocialPlatforms%5F%5Fc,Hubspot%5FTotalTwtFollowers%5F%5Fc,Activity%5FCount%5F%5Fc,hubspot%5Ffirst%5Fevent%5F%5Fc,Lead%5FSource%5FDetail%5F%5Fc,Last%5FOwner%5FChange%5FDate%5F%5Fc,SDR%5F%5Fc,Elliot%5FUpdate%5FField%5F%5Fc,Lead%5FStage%5F%5Fc,Time%5Fto%5FConvert%5F%5Fc,Status%5FUnassigned%5F%5Fc,Status%5FAssigned%5F%5Fc,Status%5FAttempting%5FContact%5F%5Fc,Status%5FQualifying%5F%5Fc,Status%5FConverted%5Fto%5FOpportunity%5F%5Fc,Status%5FDead%5F%5Fc,Status%5FRemarketing%5F%5Fc,Status%5FDate%5FUnassigned%5F%5Fc,Status%5FDate%5FAssigned%5F%5Fc,Status%5FDate%5FAttempting%5FContact%5F%5Fc,Status%5FDate%5FQualifying%5F%5Fc,Status%5FDate%5FConverted%5Fto%5FOpportunity%5F%5Fc,Status%5FDate%5FDead%5F%5Fc,Status%5FDate%5FRemarketing%5F%5Fc,Previous%5FLead%5FOwner%5F%5Fc,Days%5FUnassigned%5Fto%5FAssigned%5F%5Fc,Days%5FAssigned%5Fto%5FAttempting%5FContact%5F%5Fc,Days%5FAttempting%5FContact%5Fto%5FQualifying%5F%5Fc,Days%5FQualifying%5Fto%5FConverted%5Fto%5FOpport%5F%5Fc,Days%5FQualifying%5Fto%5FDead%5F%5Fc,Days%5FQualifying%5Fto%5FRemarketing%5F%5Fc,Dead%5FLost%5FReason%5F%5Fc,Title%5FScore%5F%5Fc,Bitly%5FActivity%5FScore%5F%5Fc,Score%5FJob%5FFunction%5F%5Fc,Lead%5FScore%5F%5Fc,Lead%5FConvert%5F%5Fc,Pricing%5FCampaign%5F%5Fc,RecordTypeId%5Faccount,Twitter%5FAccount%5F%5Fc,Facebook%5FPage%5F%5Fc,Bitly%5FUsername%5F%5Fc,Currently%5FUsing%5FBitly%5F%5Fc,Total%5FClosed%5FRevenue%5F%5Fc,Total%5FOpen%5FRevenue%5F%5Fc,HubSpot%5FInc%5F%5FSync%5FFrom%5FHubSpot%5F%5Fc,Intuit%5FSFforQB%5F%5FCredit%5FLimit%5F%5Fc,Intuit%5FSFforQB%5F%5FCustomer%5FList%5FId%5F%5Fc,Intuit%5FSFforQB%5F%5FDataSync%5FModified%5FDate%5F%5Fc,Intuit%5FSFforQB%5F%5FEmail%5F%5Fc,Intuit%5FSFforQB%5F%5FFirst%5FName%5F%5Fc,Intuit%5FSFforQB%5F%5FLast%5FName%5F%5Fc,Intuit%5FSFforQB%5F%5FOpen%5FBalance%5F%5Fc,Intuit%5FSFforQB%5F%5FQuickBooks%5FCategory%5FType%5F%5Fc,Intuit%5FSFforQB%5F%5FReady%5FTo%5FSync%5F%5Fc,Intuit%5FSFforQB%5F%5FSalesRep%5F%5Fc,Intuit%5FSFforQB%5F%5FTerms%5F%5Fc,Total%5FOpen%5FRenewal%5FRevenue%5F%5Fc,Vertical%5F%5Fc,Active%5FClient%5F%5Fc,Client%5FTier%5F%5Fc,Domain%5FUnique%5FID%5F%5Fc,Decodes%5FOrganic%5F%5Fc,Encodes%5FOrganic%5F%5Fc,Last%5FData%5FUpdate%5F%5Fc,Top%5FGHash%5F1%5F%5Fc,Top%5FGHash%5F2%5F%5Fc,Top%5FGHash%5F3%5F%5Fc,Top%5FGHash%5F4%5F%5Fc,Top%5FGHash%5F5%5F%5Fc,Click%5FCount%5F1%5F%5Fc,Click%5FCount%5F2%5F%5Fc,Click%5FCount%5F3%5F%5Fc,Click%5FCount%5F4%5F%5Fc,Click%5FCount%5F5%5F%5Fc,Account%5FRevenue%5F%5Fc,Receive%5FBitly%5FNewsletter%5F%5Fc,LinkedIn%5FMember%5FToken%5F%5Fc,Skype%5F%5Fc,Timezone%5F%5Fc,Left%5FCompany%5F%5Fc,Receive%5Fnewsletter%5F%5Fc,Intuit%5FSFforQB%5F%5FCustomer%5FListID%5F%5Fc,Intuit%5FSFforQB%5F%5FQuickBooks%5FPrimary%5FContact%5F%5Fc,Username%5F%5Fc,Admin%5FUsername%5F%5Fc,Created%5FBy%5FText%5F%5Fc,Bitly%5FUser%5F%5Fc,Role%5F%5Fc,Top%5FLink%5F1%5F%5Fc,Top%5FLink%5F2%5F%5Fc,Top%5FLink%5F3%5F%5Fc,Top%5FLink%5F4%5F%5Fc,Top%5FLink%5F5%5F%5Fc,mkto%5Fsi%5F%5FHideDate%5F%5Fc,mkto%5Fsi%5F%5FMSIContactId%5F%5Fc,mkto%5Fsi%5F%5FSales%5FInsight%5F%5Fc,Number%5Fof%5FEmployees%5F%5Fc,Number%5Fof%5FEmployees%5F%5Fc%5Faccount,Conversion%5FTemplate%5F%5Fc,Lead%5FNumber%5F%5Fc,Round%5FRobin%5FID%5F%5Fc,jsImpacts%5F%5FAdded%5Ffrom%5FData%5Fcom%5F%5Fc,jsImpacts%5F%5FData%5Fcom%5Fdo%5Fnot%5Fauto%5Fupdate%5F%5Fc,jsImpacts%5F%5FData%5Fcom%5Fmanaged%5F%5Fc,jsImpacts%5F%5FImported%5Ffrom%5FJigsaw%5F%5Fc,jsImpacts%5F%5FAdded%5Ffrom%5FData%5Fcom%5F%5Fc%5Faccount,jsImpacts%5F%5FData%5Fcom%5FManaged%5F%5Fc%5Faccount,jsImpacts%5F%5FData%5Fcom%5FMatched%5F%5Fc,jsImpacts%5F%5FData%5Fcom%5Fdoes%5Fnot%5Fauto%5Fupdate%5F%5Fc,jsImpacts%5F%5FImported%5Ffrom%5FJigsaw%5F%5Fc%5Fcontact,custom%5Fcname,Customer%5FSegment%5F%5Fc,Update%5Fvia%5FMarketo%5F%5Fc,Total%5FActive%5FRevenue%5F%5Fc,GSD%5FAward,Account%5FRevenue%5F%5Fc%5Flead,Campaign%5FNew%5FEmail%5F%5Fc,Vertical%5F%5Fc%5Flead,Social%5FMedia%5FTools%5FIntegrations%5F%5Fc,Agencies%5F%5Fc,Parent%5FCompany%5F%5Fc,Parent%5FCompany%5Fdel%5F%5Fc,Number%5Fof%5FSeats%5F%5Fc,Number%5Fof%5FDomains%5F%5Fc,API%5FCall%5FLimit%5F%5Fc,Publicity%5FContract%5FLanguage%5F%5Fc,Number%5Fof%5FBitly%5FAccounts%5F%5Fc,Upsell%5FPotential%5F%5Fc,Notes%5F%5Fc,Onboarding%5FComplete%5FDate%5F%5Fc,Company%5FSize%5F%5Fc,Website%5FAdditional%5FComments%5F%5Fc,Website%5FUsing%5FBrand%5FTools%5Ffor%5F%5Fc,Lead%5FSource%5FDetail%5FC%5F%5Fc,Lead%5FSource%5FType%5F%5Fc,Drip%5FExpire%5F%5Fc,Activate%5FDrip%5F%5Fc,Has%5FComments%5F%5Fc,Create%5FMonth%5F%5Fc,Active%5FPrice%5FIncrease%5FMRR%5F%5Fc,Active%5FRenewal%5FMRR%5F%5Fc,Open%5FRenewal%5FMRR%5F%5Fc,Queue%5FLead%5FCompany%5FSize%5F%5Fc,Success%5FManager%5F%5Fc,Open%5FNew%5FBusiness%5FMRR%5F%5Fc,SEM%5FGoogle%5FLead%5F%5Fc,SEM%5FBing%5FLead%5F%5Fc,SEM%5FLead%5F%5Fc,Account%5FCount%5F%5Fc,Total%5FActive%5FMRR%5F%5Fc,Churn%5FRisk%5F%5Fc,Parent%5FOwner%5F%5Fc,Open%5FRenewal%5FMRR%5Fdel%5F%5Fc,Total%5FOpen%5FNB%5FMRR%5F%5Fc,Open%5FRenewal%5FMRR%5Fdel%5Fdel%5F%5Fc,Integrated%5Fwith%5FBitly%5F%5Fc,Function%5Fof%5FPlatform%5F%5Fc,Key%5FUsage%5FMetric%5F%5Fc,Nature%5Fof%5FIntegration%5F%5Fc,Lead%5FCount%5F%5Fc"
request_url = marketo_instance + endpoint + auth_token + filter_type_and_values + fields
#Make request
response = RestClient.get request_url
#Returns Marketo API response
puts response
end
The error message I got:
/Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/abstract_response.rb:48:in `return!': 500 Internal Server Error (RestClient::InternalServerError)
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:246:in `process_result'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:188:in `block in transmit'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:852:in `start'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:182:in `transmit'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:68:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:35:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient.rb:71:in `get'
from get_leads.rb:21:in `block in <main>'
Can you provide the raw request and response? You can redact the access token, and munchkin id.
______
Sorry, no, I just need the raw request and response from your call. I don't need your access token or munchkin id. I suggest you edit your post to remove both of those. Thanks.
Request:
Response:
/Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/abstract_response.rb:48:in `return!': 500 Internal Server Error (RestClient::InternalServerError)
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:246:in `process_result'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:188:in `block in transmit'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/net/http.rb:852:in `start'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:182:in `transmit'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:68:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient/request.rb:35:in `execute'
from /Library/Ruby/Gems/2.0.0/gems/rest_client-1.8.3/lib/restclient.rb:71:in `get'
from get_leads.rb:21:in `block in <main>'
from get_leads.rb:12:in `each'
from get_leads.rb:12:in `<main>'
It looks like it's not even making to the the API layer. You'll need to file a support ticket so that our Engineering team can look at this.