Marketo "Import Lead" fails with error 610 Requested resource not found - rest

I'm trying to batch update a bunch of existing records through Marketo's REST API. According to the documentation, the Import Lead function seems to be ideal for this.
In short, I'm getting the error "610 Resource Not Found" upon using the curl sample from the documentation. Here are some steps I've taken.
Fetching the auth_token is not a problem:
$ curl "https://<identity_path>/identity/oauth/token?
grant_type=client_credentials&client_id=<my_client_id>
&client_secret=<my_client_secret>"
Proving the token is valid, fetching a single lead isn't a problem as well:
# Fetch the record - outputs just fine
$ curl "https://<rest_path>/rest/v1/lead/1.json?access_token=<access_token>"
# output:
{
"requestId": "ab9d#12345abc45",
"result": [
{
"id": 1,
"updatedAt": "2014-09-18T13:00:00+0000",
"lastName": "Potter",
"email": "harry#hogwartz.co.uk",
"createdAt": "2014-09-18T12:00:00+0000",
"firstName": "Harry"
}
],
"success": true
}
Now here's the pain, when I try to upload a CSV file using the Import Lead function. Like so:
# "Import Lead" function
$ curl -i -F format=csv -F file=#test.csv -F access_token=<access_token>
"https://<rest_path>/rest/bulk/v1/leads.json"
# results in the following error
{
"requestId": "f2b6#14888a7385a",
"success": false,
"errors": [
{
"code": "610",
"message": "Requested resource not found"
}
]
}
The error codes documentation only states Requested resource not found, nothing else. So my question is: what is causing the 610 error code - and how can I fix it?
Further steps I've tried, with no success:
Placing the access_token as url parameter (e.g. appending '?access_token=xxx' to the url), with no effect.
Stripping down the CSV (yes, it's comma seperated) to a bare minimum (e.g. only fields 'id' and 'lastName')
Looked at the question Marketo API and Python, Post request failing
Verified that the CSV doesn't have some funky line endings
I have no idea if there are specific requirements for the CSV file, like column orders, though...
Any tips or suggestions?

Error code 610 can represent something akin to a '404' for urls under the REST endpoint, i.e. your rest_path. I'm guessing this is why you are getting that '404': Marketo's docs show REST paths as starting with '/rest', yet their rest endpoint ends with /rest, so if you follow their directions you get an url like, xxxx.mktorest.com/rest/rest/v1/lead/..., i.e. with '/rest' twice. This is not correct. Your url must have only one 'rest/'.

I went through the same trouble, just want to share some points that help resolve my problem.
Bulk API endpoints are not prefixed with ‘/rest’ like other endpoints.
Bulk Import uses the same permissions model as the Marketo REST API and does not require any additional special permissions in order to use, though specific permissions are required for each set of endpoints.
As #Ethan Herdrick suggested, the endpoints in the documentation are sometimes prefixed with an extra /rest, make sure to remove that.
If you're a beginner and need step-by-step instructions to set up permissions for Marketo REST API: Quick Start Guide for Marketo REST API

Related

GCS storage create folder API

Having trouble creating folder in a bucket in Google Cloud storage thru a API
I have already tried the curl call for the API with all varying possibilities for the request json format.
ABC is not really the organization but gave it to obfuscate real data. I have also setup the variable $access_token using gcloud call to get access-token.
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $access_token" -d '{"displayName":"[vicks]"}' https://cloudresourcemanager.googleapis.com/v2/folders?parent=ABC
{
"error": {
"code": 400,
"message": "field [Folder.display_name] has issue [invalid format]",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "Folder.display_name",
"description": "invalid format"
}
]
}
]
}
}
I am expecting the API call to create the directory but it fails showing error in display_name format though I have followed the document at https://cloud.google.com/resource-manager/docs/creating-managing-folders
Unfortunately, the link you provided is about the API that will help you create a folder within your organization and not inside a Cloud Storage bucket. This can be seen by looking at the first graph in the page you linked.
Thankfully, there is still a solution that might help you achieve what you’re looking for. While Google Cloud Storage objects are stored in a flat namespace, tools like gsutil or the even the Google Cloud Console can provide a hierarchical view of the objects by following simple naming rules (it is essentially an emulation of subdirectories).
1) To treat an object as a directory, you can create an empty object that ends with “/”. If you want a subdirectory called ‘abc’ then you can call the object ‘abc/’ and gsutil will treat it like an empty directory. To insert an object/file into the subdirectory, you may simply copy an object/file to the destination URL including ‘abc’ such as “gs://your-bucket/abc”.
2) Another less commonly used way is to create an empty object that ends with “$folder$”. If you want a subdirectory called ‘abc’ then you can call the object ‘abc$folder$’ and gsutil will treat it like an empty directory. Similarly to the previous point, to insert an object/file into the subdirectory, you may simply copy an object/file to the destination URL including ‘abc’ such as “gs://your-bucket/abc”.
I would highly suggest you read through this link to get a great understanding of how Google Cloud Storage subdirectories work. Additionally, I’ve found another previously answered stack question that is very relevant to your question and can be of great help to you as well.

Smartsheet API response codes with python SDK?

I am using the Smartsheet python SDK to do bulk operations (deletes, updates, etc.) on a Smartsheet. As my process becomes more complex, I've realized that I need to include some internal checks to make sure I am not encountering errors when sending multiple calls per minute as Smartsheet suggests in their API Best Practices.
My question is this: How do I access and parse the API responses while using SDK functions such as Sheets.delete_rows()? For instance, some of my requests using this function can trigger status: 500 Internal Server Error which mean the request was properly formatted but the operation failed on the Smartsheet end.
I can view these responses in my log file (or in terminal while running interactively) but how do I access them from within my script so I can, for example, sleep() my process for xx seconds if encountering such a response?
If you are looking to know the results of a request you can store the response in a variable and inspect that for determining the next steps your process should take. In the case of the DELETE Rows request a Result object is returned.
deleteRows = smartsheet_client.Sheets.delete_rows({{sheetId}}, [ {{rowId1}}, {{rowId2}}, {{rowId3}}])
print(deleteRows)
If the request was successful the response would look like this:
{"data": [7411278123689860], "message": "SUCCESS", "result": [7411278123689860], "resultCode": 0}
If there was an issue, rows weren't found for example, the response would look like this:
{"result": {"code": 1006, "errorCode": 1006, "message": "Not Found", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": "jv6o8uyrya2s", "shouldRetry": false, "statusCode": 404}}
All of the Smartsheet SDKs will backoff and retry by default. Other errors will be thrown as exceptions.
There is a way to increase the default timeout (to allow more retries) when creating the client. However, the Python-specific way to do it doesn't seem to be documented yet. I'll add it to the queue. In the meantime, I think the Ruby example below will be the closest to how Python probably does it, but you might want to read through the various ways to do this.
C#: https://github.com/smartsheet-platform/smartsheet-csharp-sdk/blob/master/ADVANCED.md#sample-retryhttpclient
Java: https://github.com/smartsheet-platform/smartsheet-java-sdk/blob/master/ADVANCED.md#sample-retryhttpclient
Node.js: https://github.com/smartsheet-platform/smartsheet-javascript-sdk#retry-configuration
Ruby: https://github.com/smartsheet-platform/smartsheet-ruby-sdk#retry-configuration

Get Reactions using the Github api

Github issues may contain "reactions" for quite a while (as described here: https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments)
I would like to receive that information using the Github api, but there doesn't seem to be anything like that when getting an issue e.g.
api.github.com/repos/twbs/bootstrap/issues/19575
that information does not seem to be inside that response. Also, I did not find another API call that could retrieve that information. How to get those "reactions"?
This is now possible, being the preview state (meaning, you have to pass a custom Accept header in the request). Check out the GitHub API documentation page
Example
$ curl -H 'Accept: application/vnd.github.squirrel-girl-preview' https://api.github.com/repos/twbs/bootstrap/issues/19575/reactions
[
{
"id": 257024,
"user_id": 947110,
"content": "+1"
},
...
{
"id": 888868,
"user_id": 1889800,
"content": "+1"
}
]
The endpoint looks like this:
GET /repos/:owner/:repo/issues/:number/reactions
You can even pass a content parameter (querystring) indicating what kind of reaction you want to retrieve.

Google Fit REST API "Unable to fetch DataSource for Dataset: xyz"

I'm testing out a few things in the OAuth 2.0 Playground and trying to get data in and out of Google Fit using their REST API
I have done this previously with success, I just didn't write down what I did.. now I've come back to make it a proper thing and can't get it working again.
I have access to Google Fit datasources via the dashboard. I can get a list of the dataSources that exist from:
https://www.googleapis.com/fitness/v1/users/me/dataSources
And that is successful. I have also created my own stream which has a single floating point weight value on it called
raw:com.google.weight:b6ac18c0:dten.sync
It already has data in it, I put it there last time I used it. I can select all that data by requesting a GET on the following
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/0-1432193482000000000
It returns me all the data points I entered last time as JSON
I then try to PATCH the data adding my own data to the folliwng URL
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/1432193482000000000-1432193482000000000
With this as a the request body
{
"minStartTimeNs": "1421912895000000000",
"maxEndTimeNs": "1432193482000000000",
"dataSourceId": "raw:com.google.weight:b6ac18c0:dten.sync",
"point": [
{
"startTimeNanos": "1421912895000000000",
"modifiedTimeMillis": "1421912895000",
"endTimeNanos": "1421912895000000000",
"value": [
{
"fPVal": 89.1
}
],
"dataTypeName": "com.google.weight"
}
]
}
But I get back
{
"error": {
"code": 400,
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"errors": [
{
"domain": "global",
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"reason": "invalidArgument"
}
]
}
}
I can't find any one referencing a similar anywhere soo I'm here
Also note if I miss spell my source it tells me off because they don't match the URL, if i include an empty list of data points I get the same error. I'm quite lost so I'm throwing it out there to see if anyone knows what that means
Thanks in advance
edit: i tried changing the hex code for my project's integer code and got an error about untrusted source. so i tried making a new test data source which works as expected. Slightly annoyed but guess I'll just start over..
OK I was stupid and didn't set up my own credentials in the OAuth settings in top right of the dashboard as it said to here. I forgot that bit -_- now I can access my own stream again and it shows my integer project id in the stream id not the hex one
https://developers.google.com/fit/rest/v1/get-started
Now I get invalid argument, but.. whatever >_<
edit 2:
invalid argument was because I have fPVal instead of fpVal and modifiedTimeMillis mills is not supposed to be submitted, obviously

I keep getting error 422 when trying to start process instance using REST API

I'm trying to use the REST API, from Postman REST client on Chrome.
Here's my screenshot:
I keep getting error 422: "The server understands the content type of the request entity and the syntax of the request entity is correct but was unable to process the contained instructions".
I'm using Activiti 5.16.3 on MacOS Maverick, with Java 1.8.
The process I tried to call is the one that comes with the demo of Activiti, Vacation Request.
The JSON payload in my request is:
{
"processDefinitionKey":"vacationRequest",
"variables":[
{"name": "employeeName", "value": "Raka","type":"string"},
{"name": "numberOfDays", "value": "5", "type":"integer"},
{"name": "vacationMotivation", "value": "", "type":"string"},
{"name": "startDate", "value": "01-01-2014 11:11", "type":"date"}
]
}
Oh, and I had to add a header "Content-Type" with its value set to "application/json" (otherwise I'd get error code 415: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method").
What am I missing?
Btw, I need to be able to demonstrate the use of the REST API through tools like Postman. So, no Java code. It's because another programmer (front-end) will interact directly with Activiti bpm.
Thanks in advance for your help. This is really critical.
**
Additional comments:
I didn't have issue with other REST methods that are GET (for example: listing process definitions, etc). Looks like I'm only having trouble with POST (and maybe PUT too).
Not much info on this on google: https://www.google.com/search?as_q=rest+422&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforums.activiti.org&as_occt=any&safe=images&as_filetype=&as_rights=&gws_rd=ssl
I've tried also this suggestion. Didn't work for me: http://forums.activiti.org/comment/23039#comment-23039
**
Best regards,
Raka
Solved now....
Looks like there should be no whitespace between the opening { and the rest of the document.
Here's my screenshot: