0

I'm trying to add products to my guest cart, passing the guest_id in the url and the listings_id in the body. This is the method:

addToGuestCart(){
    this.http.post(`https://openapi.etsy.com/v2/guests/${this.guest.guest_id}/carts?api_key=my-api-key`, this.product.listing_id)
      .first()
      .subscribe(()=>this.getGuest());
  }

I get this cors error:

XMLHttpRequest cannot load https://openapi.etsy.com/v2/guests/akye30nuit6ua/carts?api_key=my-api-key. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

cerealex
  • 1,649
  • 4
  • 17
  • 37

1 Answers1

0

Input of HTTP POST body is object so you should use : { listing_id: this.product.listing_id }

I read in https://www.etsy.com/developers/documentation/reference/guestcart , I think you should send [listing_id] via url as :

/guests/:guest_id/carts?api_key=my-api-key&listing_id=listing_id_value

Thien Hoang
  • 625
  • 3
  • 12
  • I can't send the value through the url because http.post requires a body argument. Using {listing_id: this.product.listing_id} in the body returns the same 'Access-Control-Allow-Origin' error from before but instead of an HTTP status code of 500 now I get 400. – cerealex Jun 02 '17 at 13:36