檔案
Marketo訂閱可儲存任意檔案,例如影像、指令碼、檔案和樣式表。 所有這些都可以透過REST API從遠端使用。 Marketo訂閱提供的儲存空間並未針對頻寬密集的應用程式進行最佳化,因此應該使用替代方案來處理適當的音訊與視訊串流應用程式。
查詢
查詢檔案非常簡單,並遵循的資產(依識別碼、依名稱和瀏覽)的標準查詢型別。
依Id
GET /rest/asset/v1/file/{id}.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":null,
"result":[
{
"id":147,
"size":61346,
"mimeType":"image/jpeg",
"url":"http://mlm.devlocal.marketo.com/rs/test/assets/rYXNeQFFVu",
"folder":{
"type":"Email",
"id":10613
},
"name":"rYXNeQFFVu",
"description":null,
"createdAt":"2014-12-09T22:33:57Z+0000",
"updatedAt":"2014-12-09T22:33:57Z+0000"
}
]
}
依名稱
使用必要的name引數指定檔案的名稱。
GET /rest/asset/v1/file/byName.json?name=foo.png
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "9049#15918a76619",
"result": [
{
"id": 46488,
"size": 13987,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/foo.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images"
},
"name": "foo.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T22:16:58Z+0000",
"updatedAt": "2015-05-06T22:19:29Z+0000"
}
]
}
瀏覽
有三個可選引數:
- 資料夾 — 指定為包含「id」和「type」屬性的JSON區塊的父資料夾
- offset — 指定從何處開始擷取專案的整數(預設為0);可搭配maxReturn引數使用
- maxReturn — 指定傳回專案數上限的整數(預設為20,上限為200)
GET /rest/asset/v1/files.json?folder={"id":436, "type": "Folder"}&maxReturn=3
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "17e4e#14e23372d80",
"result": [
{
"id": 46484,
"size": 1454,
"mimeType": "text/plain",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/websites.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "websites.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T20:15:58Z+0000",
"updatedAt": "2015-06-22T02:12:36Z+0000"
},
{
"id": 46486,
"size": 4169,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/mobile.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "mobile.png",
"description": null,
"createdAt": "2015-05-06T22:13:33Z+0000",
"updatedAt": "2015-05-06T22:13:33Z+0000"
},
{
"id": 46488,
"size": 13987,
"mimeType": "image/png",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/foo.png",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "foo.png",
"description": "This is a test file.",
"createdAt": "2015-05-06T22:16:58Z+0000",
"updatedAt": "2015-05-06T22:19:29Z+0000"
}
]
}
建立和更新
建立檔案已使用請求的多重部分/表單資料型別完成。 最低限度,要求中必須包含名稱、資料夾和檔案,並附上可選說明和insertOnly旗標,以防止建立呼叫更新具有相同名稱的現有檔案。 對於檔案引數,除了name引數之外,Content-Disposition標頭中還需要「filename」。 您也必須傳遞檔案的Content-Type標頭,該標頭將為Marketo用來提供檔案的MIME型別。
POST /rest/asset/v1/files.json
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="file"; filename="marketo.html"
Content-Type: text/html
<html>
<body>
<h1>Test Page - marketo.html</h1>
</body>
</html>
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="name"
marketo.html
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="folder"
{"id":436,"type":"Folder"}
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="description"
This is a test file
------WebKitFormBoundary2VyWOacQSupl4gUL—
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "278d#14e23316f63",
"result": [
{
"id": 46960,
"size": 69,
"mimeType": "text/html",
"url": "http://na-abm.marketo.com/rs/mktodemoaccount88/assets/marketo.html",
"folder": {
"type": "Image",
"id": 436,
"name": "My Images - deverly"
},
"name": "marketo.html",
"description": "This is a test file",
"createdAt": "2015-06-24T01:31:59Z+0000",
"updatedAt": "2015-06-24T01:31:59Z+0000"
}
]
}
可依據檔案的ID更新檔案。 唯一的引數是要求與建立相同的檔案引數。
POST /rest/asset/v1/file/{id}/content.json
------WebKitFormBoundary2VyWOacQSupl4gUL
Content-Disposition: form-data; name="file"; filename="marketo.html"
Content-Type: text/html
<html>
<body>
<h1>Test Page - marketo.html</h1>
</body>
</html>
------WebKitFormBoundary2VyWOacQSupl4gUL--
{
"success": true,
"warnings": [],
"errors": [],
"requestId": null,
"result": [
{
"id": 67,
"size": 512000,
"mimeType": "image/png",
"url": "http://pages.devlocal.marketo.com/rs/test/assets/aLZiwCkXor",
"folder": {
"type": "Email",
"id": 10391
},
"name": "aLZiwCkXor",
"description": null,
"createdAt": "2014-12-18T09:03:43Z+0000",
"updatedAt": "2015-01-07T04:40:20Z+0000"
}
]
}
recommendation-more-help
bb269a6d-047a-4bf7-9acd-23ad9a63dc59