Requesting ICloud API and login by using below URL
string url = "https://setup.icloud.com/setup/ws/1/login?clientBuildNumber=1P24&clientId=" + RANDOM_GUID;
Getting server url and dsid from above url response. Further requesting for Contact list by using below code
var localUrl2 = "https://p66-contactsws.icloud.com/co/startup?clientBuildNumber=1P24&clientId=" + RANDOM_GUID + "&clientVersion=2.1&dsid=" + dsid + "&locale=en-EN&order=last%2Cfirst";
var webRequest2 = (HttpWebRequest)WebRequest.Create(localUrl2);
webRequest2.Method = "GET";
webRequest2.Headers.Set("Origin", "https://www.icloud.com");
// get the X-APPLE-WEBAUTH-TOKEN and X-APPLE-WEBAUTH-USER from webResponse.Headers.SetCookie
webRequest2.Headers.Set("X-APPLE-WEBAUTH-TOKEN", XXXXXXX);
webRequest2.Headers.Set("X-APPLE-WEBAUTH-USER", XXXXXXXX);
WebResponse webResponse2 = webRequest2.GetResponse();
Still getting exception
The remote server returned an error: (421) Misdirected Request.
Please let me know what is wrong in above code.
Can I view my contacts on iCloud from Android devices? You can go to iCloud.com on your Android browser and access all the contacts synced to your iCloud account.
iCloud Storage APIs allow you to store your app's data in iCloud. System services sync your data automatically even when your app isn't running.
As mentioned in the comments, Apple has taken the end point you are trying to reach offline hence the 421 error. You can look into another way to accomplish this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With