Word of warning: it's 10 MB, and pretty hard-core.
If you're writing a private app (as opposed to a public one), things are much simpler; you don't need all the OAuth stuff for starters. After a bit of trial and error, I got this to work:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetCustomers() | |
{ | |
const string url = "https://your-store.myshopify.com/admin/customers.json"; | |
var req = (HttpWebRequest)WebRequest.Create(url); | |
req.Method = "GET"; | |
req.ContentType = "application/json"; | |
req.Credentials = GetCredential(url); | |
req.PreAuthenticate = true; | |
using (var resp = (HttpWebResponse)req.GetResponse()) | |
{ | |
if (resp.StatusCode != HttpStatusCode.OK) | |
{ | |
string message = String.Format("Call failed. Received HTTP {0}", resp.StatusCode); | |
throw new ApplicationException(message); | |
} | |
var sr = new StreamReader(resp.GetResponseStream()); | |
return sr.ReadToEnd(); | |
} | |
} | |
private static CredentialCache GetCredential(string url) | |
{ | |
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; | |
var credentialCache = new CredentialCache(); | |
credentialCache.Add(new Uri(url), "Basic", new NetworkCredential("your-api-key", "your-password")); | |
return credentialCache; | |
} |
Hello,
ReplyDeleteI have used this for fetching my shopify store details like customers, orders datas for the .net windows service through the above code..
Its works awesomely..
Thanks to U sir...
Hi,
ReplyDeleteI tried above code but i got error ''The request was aborted: Could not create SSL/TLS secure channel.'' please help me.
@Vikram: you need to add this line to enable SSL/TLS:
ReplyDeleteServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
This works great! Thanks ever so much!
ReplyDeletehi i tried this but unable to run it.. "couldn't locate the web.config file".. Please help me in this
ReplyDeletethanks!!
ReplyDelete