Hi,
I'm trying to use get data of marketo using bulk api. here is my code..
package main
import(
"github.com/SpeakData/minimarketo"
"log"
"encoding/json"
"fmt"
)
type DataRangeType struct {
StartAt string json:"startAt"
EndAt string json:"endAt"
}
type ActivityType1 struct {
ActivityTypeIds []int json:"activityTypeIds"
}
type FilterType struct {
CreatedAt DataRangeType json:"createdAt"
ActivityTypeIds []int json:"activityTypeIds"
}
type InputActivity1 struct {
Format string json:"format"
Filter FilterType json:"filtertype"
}
type BulkOutputResult struct {
RequestID string json:"requestId"
Success bool json:"success"
Result []struct {
ExportID string json:"exportId"
Status string json:"status"
CreatedAt string json:"createdAt"
QueuedAt string json:"queuedAt"
Format string json:"format"
} json:"result"
}
func main() {
config := minimarketo.ClientConfig{
ID: "ID",
Secret: "SCRET",
Endpoint: "https://XYZ.mktorest.com",
Debug: true,
}
fmt.Println("before calling client")
client, err := minimarketo.NewClient(config)
if err != nil {
log.Fatal(err)
}
vinput := InputActivity1 {Format: "CSV",Filter: FilterType{CreatedAt: DataRangeType{StartAt:"2017-01-21T11:47:30-08:00", EndAt:"2017-01-21T11:47:30-08:00"}, ActivityTypeIds: []int{12,1},},}
path := "/bulk/v1/activities/export/create.json"
dataInBytes, err := json.Marshal(vinput)
fmt.Println("json input",dataInBytes)
response, err := client.Post(path, dataInBytes)
if err != nil {
fmt.Println("error in post")
log.Fatal(err)
}
if !response.Success {
log.Fatal(response.Errors)
}
var createResults []BulkOutputResult
if err = json.Unmarshal(response.Result, &createResults); err != nil {
log.Fatal(err)
}
for _, result := range createResults {
fmt.Printf("%+v", result)
}
}
Getting an error . Can you please let me know where I'm making a mistake.
2017/08/20 18:25:31 [minimarketo/Post] /bulk/v1/activities/export/create.json, {"format":"CSV","filtertype":{"createdAt":{"startAt":"2017-01-21T11:47:30-08:00","endAt":"2017-01-21T11:47:30-08:00"},"activityTypeIds":[12,1]}}
2017/08/20 18:25:31 [minimarketo/do] URL: https://XYZ.mktorest.com/rest/v1/bulk/v1/activities/export/create.json
2017/08/20 18:25:31 [minimarketo/do] DONE: body
2017/08/20 18:25:31 [minimarketo/Post] DONE
error in post
2017/08/20 18:25:31 No body! Check URL: https://XYZ.mktorest.com/rest/v1/bulk/v1/activities/export/create.json
Hi,
I'm trying to use get data of marketo using bulk api. here is my code..
package main
import(
"github.com/SpeakData/minimarketo"
"log"
"encoding/json"
"fmt"
)
type DataRangeType struct {
StartAt string
json:"startAt"EndAt string
json:"endAt"}
type ActivityType1 struct {
ActivityTypeIds []int
json:"activityTypeIds"}
type FilterType struct {
CreatedAt DataRangeType
json:"createdAt"ActivityTypeIds []int
json:"activityTypeIds"}
type InputActivity1 struct {
Format string
json:"format"Filter FilterType
json:"filtertype"}
type BulkOutputResult struct {
RequestID string
json:"requestId"Success bool
json:"success"Result []struct {
ExportID string
json:"exportId"Status string
json:"status"CreatedAt string
json:"createdAt"QueuedAt string
json:"queuedAt"Format string
json:"format"}
json:"result"}
func main() {
config := minimarketo.ClientConfig{
ID: "ID",
Secret: "SCRET",
Endpoint: "https://XYZ.mktorest.com",
Debug: true,
}
fmt.Println("before calling client")
client, err := minimarketo.NewClient(config)
if err != nil {
log.Fatal(err)
}
}
Getting an error . Can you please let me know where I'm making a mistake.
2017/08/20 18:25:31 [minimarketo/Post] /bulk/v1/activities/export/create.json, {"format":"CSV","filtertype":{"createdAt":{"startAt":"2017-01-21T11:47:30-08:00","endAt":"2017-01-21T11:47:30-08:00"},"activityTypeIds":[12,1]}}
2017/08/20 18:25:31 [minimarketo/do] URL: https://XYZ.mktorest.com/rest/v1/bulk/v1/activities/export/create.json
2017/08/20 18:25:31 [minimarketo/do] DONE: body
2017/08/20 18:25:31 [minimarketo/Post] DONE
error in post
2017/08/20 18:25:31 No body! Check URL: https://XYZ.mktorest.com/rest/v1/bulk/v1/activities/export/create.json