Giter Club home page Giter Club logo

rest-sample-code's People

Contributors

budster650 avatar dmitry-me avatar everlyd avatar jonasagx avatar msaz87 avatar vinhchung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest-sample-code's Issues

MergeLeads.php has an error

The program to MergeLeads has a function called csvString. In that function, there is an incrementer $i. However, $i is never incremented, on line 52, please add $i++; So that the ideas are properly joined by commas

Marketo Email Insight vs Email Insight API Data

Hi
I am using Rest api to export lead activities using "activities" API. I am able to fetch the activity data, but when I match day wise data count from exported data against the data count from marketo, I am having count difference. Minor difference is understandable. Please suggest.

Testing PHP Code:

$url = $this->host . "/rest/v1/activities.json?access_token=" "&activityTypeIds=9,10,11&nextPageToken=" . $this->nextPageToken;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
$response = curl_exec($ch);

Thanks.

No example for push.json request

I'm unclear how to upsert to the push.json endpoint.

I've successfully pushed to Marketo, and associated the lead by email, but it fails to continue tracking events like page visits and link clicking once that happened. I assume the cookie value was sent incorrectly.

Every example that I see has the cookie being urlencoded()'d, and then sent as part of the URL. I'm trying to send it as part of the mktToken field in the input array of JSON objects.

Does this look right, or am I screwing this up?

        $curl_post_data = json_encode(array(
                            "lookupField" => "email",
                            "reason" => "Logged in",
                            "input" => array(
                                array(
                                   "email" => $userEmail,
                                   "mktToken" => urlencode(filter_input(INPUT_COOKIE, "_mkto_trk")), 
                                   "UserName" => $user['username']
                                )
                            ),
                            "programName" => "Lead Acquisition"
                        )
        );

Or should I not urlencode the cookie value?

Clone Email Response Error

Guys, could you please provide a solution?
Can't clone some of our emails.

Request:

POST https://xxx.mktorest.com/rest/asset/v1/email/xxx/clone.json?access_token=xxx

&name=xxx - [it-it]&folder={"id":14,"type":"Folder"}

Response:

{"requestId":"12caa#1636d21b670","success":false,"errors":[{"code":"611","message":"System error"}]}

Auth for Pushleads

Your PushLeadToMarketo.php example seems pretty straightforward, much simpler than the convoluted Marketo REST api docs I have seen so far. With that said, since I have no direct experience with Marketo yet, how should I direct a Marketo customer to get me the following details and make sure it has the right permissions for me to simply push leads to their system. This is from within your example:

	private $host = "";//CHANGE ME
	private $clientId = "";//CHANGE ME
	private $clientSecret = "";//CHANGE ME

Also, are there no such things as leads list that they can be added to instead of some programname with a static string that does not appear to be predefined within marketo.

Sample Code for requests to Smartlists endpoint

I am attempting to send a request to '/rest/asset/v1/smartLists.json' to get all SmartLists. I am authenticating with Marketo fine and recieving an access token that I include in the headers of each of my subsequent requests . Additionally, the documentation states that if our instance did not have this capability, the response code would be >1000 (It's some number I can't remember off the top of my head). However, I did not get this response code, but rather 403, which is a forbidden request. I am hoping to figure out why I am not getting a valid response, but there is no documentation for troubleshooting this endpoint.

Code:
`

def get_smartlist_ids(config, access_token):

    identity_url = config['identity_url']

    headers = {
        'Authentication': 'Bearer {}'.format(access_token),
    }

    url = '{}/rest/asset/v1/smartLists.json'.format(identity_url)

    response = requests.get(url, headers=headers)

    return response


 mkto_config = {
    'client_id': [redacted],
    'client_secret': [redacted],
    'identity_url': [redacted]
  }
  
  access_token_response = get_mkto_access_token(mkto_config)
  access_token = access_token_response.json()['access_token']
  
  print(access_token_response.status_code)
  print(access_token_response.json())
  
  smartlist_ids = get_smartlist_ids(mkto_config, access_token)
  
  print(smartlist_ids.status_code)
  print(smartlist_ids.headers)
  print(smartlist_ids.request.headers)
  print(smartlist_ids.text)
  print(smartlist_ids.url)

`

And the Output:

`

  200
  {'access_token': '[redacted]', 'token_type': 'bearer', 'expires_in': 337, 'scope': '[email protected]'}
  403
  {'Server': 'nginx', 'Date': 'Thu, 29 Sep 2022 17:54:55 GMT', 'Content-Type': 'text/html', 'Content-Length': '162', 'Connection': 'keep-alive'}
  {'User-Agent': 'python-requests/2.25.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authentication': 'Bearer [redacted]'}
  <html>
  <head><title>403 Forbidden</title></head>
  <body bgcolor="white">
  <center><h1>403 Forbidden</h1></center>
  <hr><center>nginx</center>
  </body>
  </html>
  
  [redacted]/rest/asset/v1/smartLists.json

`

Let me know if I can clarify or provide more information in order to help. Thanks in advance for the help!

Export

Are you going to add the ability to use the new API to export?

API File Create Issues

Trying to move files from one Marketo instance to another. Marketo support said to use the api. The PHP code for retrieving files and folders works, but when I try to create the file from one marketo instance onto the new one using the api, I get a couldn't open file .... I am providing the file url that I get in response from the rest api for querying files.

Bulk push returns Marketo API ids

Hi,

I'm using POST: /rest/v1/leads.json with
$lookupField = email
$action = createOrUpdate
data:

[
{
  email: [email protected],
  firstName: Jacob
},
{
  email: [email protected],
  firstName: Dani
}
]

and here is an example of my response:

{
"requestId": "1ddd0#1fd5f0ssss64d",
"result": [
{
"id": 514,
"status": "updated"
},
{
"status": "skipped",
"reasons": [
{
"code": "1007",
"message": "Multiple lead match lookup criteria"
}
]
}
],
"success": true
}

is there a way to add the email to the response results using marketo api?

400 Error

Code generates a 400 error. This seems to be due to a missing CURLOPT_POSTFIELDS. However, if you try to post the access token, losing lead, and the merge in crm values as posted fields, you will get 1003 errors.

This will generate a 1003 Error
public function postData(){ $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json"; $fields = array( 'access_token' => urlencode($this->getToken()), 'leadIds' => urlencode($this::csvString($this->leadIds)), 'mergeInCRM' => urlencode('true') ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }

Sending an empty set of post fields gets rid of the 400 error
public function postData(){ $url = $url = $this->host . "/rest/v1/leads/" . $this->id ."/merge.json?access_token=" . $this->getToken() . "&leadIds=" . $this::csvString($this->leadIds); $fields = array(); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json')); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_getinfo($ch); $response = curl_exec($ch); return $response; }

Sending without the mergeInCRM parameter, returns a success. With the mergeInCRM set to true I get a 611 error when merging a contact to a lead. The call will convert the lead to a contact and assign it a new marketo ID. If you run the merge again with the existing contact and the new contact, the contacts are merged in Marketo, but not in Salesforce. It seems the API is just as poor at merging as within the marketo platform natively. It's best just to merge leads/contacts within SF.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.