Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk export API #3

Open
surajkb74 opened this issue Aug 20, 2017 · 6 comments
Open

Bulk export API #3

surajkb74 opened this issue Aug 20, 2017 · 6 comments

Comments

@surajkb74
Copy link

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

@ghiden
Copy link
Member

ghiden commented Aug 20, 2017

I've never used "bulk" endpoints before.
I didn't know that Marketo's URLs are different for bulk.
I need to change my code.
Not sure how long it'll take but I'll have a look.

@surajkb74
Copy link
Author

surajkb74 commented Aug 20, 2017 via email

@ghiden
Copy link
Member

ghiden commented Aug 20, 2017

Give it a try.
Now you need to specify the path all the time like this:
/rest/v1/leads.json
/bulk/v1/activities/export/create.json
Which is a good thing I suppose. It's more explicit.

@surajkb74
Copy link
Author

surajkb74 commented Aug 21, 2017 via email

@surajkb74
Copy link
Author

surajkb74 commented Aug 21, 2017 via email

@ghiden
Copy link
Member

ghiden commented Aug 21, 2017

Bulk API is quite different from REST-based JSON API.
At this point, we don't have a plan to support it.
What you can do is use minimarketo as a primary tool to drive your program but downloading files should be handled by your own http client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants