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

Unable to get BuyerCustomizedInfo in GetOrderItemsBuyerInfoWithResponse #35

Open
quanlndzt opened this issue Apr 23, 2024 · 0 comments
Open

Comments

@quanlndzt
Copy link

Hey team.
I try to get buyer customer infomation but it not work
The result always return empty

This is my code testing:

package main

import (
	"context"
	"fmt"
	"net/http"

	"github.com/amzapi/selling-partner-api-sdk/ordersV0"
	sp "github.com/amzapi/selling-partner-api-sdk/pkg/selling-partner"

	"github.com/google/uuid"
	"github.com/pkg/errors"
)


var (
	ClientID     = "Your ClientID"
	ClientSecret = "Your ClientSecret"
	RefreshToken = "Your RefreshToken"
	orderId = "Your OrderId"
)


func main() {

	sellingPartner, err := sp.NewSellingPartner(&sp.Config{
		ClientID:     ClientID,
		ClientSecret: ClientSecret,
		RefreshToken: RefreshToken,
	})

	if err != nil {
		panic(err)
	}

	endpoint := "https://sellingpartnerapi-na.amazon.com"

	seller, err := ordersV0.NewClientWithResponses(endpoint,
		ordersV0.WithRequestBefore(func(ctx context.Context, req *http.Request) error {
			req.Header.Add("X-Amzn-Requestid", uuid.New().String()) //tracking requests
			err = sellingPartner.AuthorizeRequest(req)
			if err != nil {
				return errors.Wrap(err, "sign error")
			}

			return nil
		}),
	)

	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	resp, err := seller.GetOrderItemsBuyerInfoWithResponse(ctx, orderId, &ordersV0.GetOrderItemsBuyerInfoParams{})


	if err != nil {
		fmt.Println("[GetOrderItemsBuyerInfoWithResponse] err : ", err)
		panic(err)
	}

	
	fmt.Println(string(resp.Body))
}

The example result . BuyerCustomizedInfo always is empty

{"payload":{"OrderItems":[{"OrderItemId":"98587589265001","BuyerCustomizedInfo":{}}],"AmazonOrderId":"113-8246998-1524200"}}

Go version: go version go1.22.2 linux/amd64
amzapi/selling-partner-api-sdk latest
Permission:
image

@quanlndzt quanlndzt changed the title Unable to get BuyerCustomizedInfo in Unable to get BuyerCustomizedInfo in GetOrderItemsBuyerInfoWithResponse Apr 23, 2024
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

1 participant