JSONP error

New Member
24 0 0

I have found the following posts in the discussion forums:

http://ecommerce.shopify.com/c/shopify-discussion/t/get-products-and-collections-from-a-different-do...

http://www.shopify.com/technology/3716152-state-of-the-api-july-29th-2011#axzz2dIEVBM1k

I have used them to create the following code:

var urlShopify = 'https://XXxxxX@xxxx.myshopify.com/admin/orders.json?callback=?';;
$.getJSON(urlShopify).done(function(x){console.log(x.order_number)});

I continually get an error that says:

Uncaught SyntaxError: Unexpected token :

This is my first attempt at JSONP and I'm not sure what I am doing wrong. Can anyone let me know what I am doing wrong?

0 Likes
Shopify Staff
Shopify Staff
582 0 45

Is this for presenting products to a customer? You can't access the admin API like that. You'll need to access the storefront (Javascript) API instead, which supports JSONP.

HunkyBill covers all of that in his comments.

0 Likes
New Member
24 0 0

This is for a Private APP for a store owner.

0 Likes
Shopify Staff
Shopify Staff
582 0 45

Then you are going to need to create a proxy.  The Admin API doesn't support JSONP.

0 Likes
New Member
24 0 0

Wow okay. Um this is way out of my league. I noticed that support for the XML API is being depreciated. How long until the XML API goes away for ever?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
582 0 45

That I don't know. The deprecation warning is more there since if future changes cause the XML to break we don't really intend on fixing it.

Working with JSON is pretty simple, and it's a far lighter format to deal with. If you aren't too deep into everything, I'd highly suggest switching over to using that. Depending on your library, it might be an easy change to make.

0 Likes
New Member
24 0 0

I'm up for the challenge regarding JSON and JSONP. Do you know of any good online tutorials when it comes to using a proxy? 

0 Likes
New Member
24 0 0

I was able get a proxy working and pulling the data just fine now. Thank you for your help, it was definitely needed.

0 Likes