Hello,
I'm trying to call http://lotmaker.dumouchelles.com:8082/api/AuctionMobile
and receive json via data source and show it in tableView or ListView.
am trying something like
base.ViewDidLoad();
UITableView tableView = new UITableView(this.View.Bounds);
this.View.AddSubview(tableView);
//string url = "http://api.myjson.com/bins/3kj37";
string url = "http://lotmaker.dumouchelles.com:8082/api/AuctionMobile";
dataSource.LoadDataFromURL(url, TKDataSourceDataFormat.JSON, "AuctionMobile", (NSError err) =>
{
if (err != null)
{
Console.WriteLine("Can't connect with the server!");
return;
}
this.dataSource.DisplayKey = "LotNumber";
tableView.DataSource = this.dataSource;
});
Any thought why I'm not getting data ?
Thanks
TYK
4 Answers, 1 is accepted
Unfortunately. even though you're using a TKDataSource, debugging your API endpoint is out of the scope of Telerik Support. However, I have some suggestions that may be useful.
I tested your first test API json and it works fine, here's the full code and attached is a screenshot at runtime (notice I have the rootItemKeyPath and DisplayKey properly defined)
public
override
void
ViewDidLoad()
{
base
.ViewDidLoad();
UITableView tableView =
new
UITableView(
this
.View.Bounds);
this
.View.AddSubview(tableView);
NSString url =
new
NSString(
"http://api.myjson.com/bins/3kj37"
);
dataSource =
new
TKDataSource();
dataSource.LoadDataFromURL(url, TKDataSourceDataFormat.JSON,
"fridayLotList"
, error =>
{
if
(error !=
null
)
{
Console.WriteLine(
"Can't connect with the server!"
);
return
;
}
dataSource.DisplayKey =
"Inv_Prim_Cat_Desc"
;
tableView.DataSource = dataSource;
});
}
I notice your second URL doesn't work, the API's server is not responding lotmaker.dumouchelles.com/API, does this API need authentication? Take a look at how to authenticate using Telerik DataSource
Lastly, you should check your debug output window to make sure you haven't forgotten to add your insecure (http) URL to the safe list. iOS only allows from https connections, see here for more info on how to accomplish this.
Here's what the error looks like in the console:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
To fix this for the test API, add the following to your Info.plist:
<
key
>NSAppTransportSecurity</
key
>
<
dict
>
<
key
>NSExceptionDomains</
key
>
<
dict
>
<
key
>api.myjson.com</
key
>
<
dict
>
<
key
>NSExceptionMinimumTLSVersion</
key
>
<
string
>TLSv1.0</
string
>
<
key
>NSExceptionRequiresForwardSecrecy</
key
>
<
false
/>
<
key
>NSExceptionAllowsInsecureHTTPLoads</
key
>
<
true
/>
<
key
>NSIncludesSubdomains</
key
>
<
true
/>
</
dict
>
</
dict
>
</
dict
>
I hope I was able to clarify some pain points, if this still doesn't work. Please update this thread when you've got a working API.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
I wanted to do a quick follow up to let you know that if you decide to use TKListView
instead of UITableView, make sure you call ReloadData() after setting the data source.
Here's my previous example but using a TKListView instead:
public
override
void
ViewDidLoad()
{
base
.ViewDidLoad();
TKListView listView =
new
TKListView(
this
.View.Bounds);
listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
this
.View.AddSubview(listView);
NSString url =
new
NSString(
"http://api.myjson.com/bins/3kj37"
);
dataSource =
new
TKDataSource();
dataSource.LoadDataFromURL(url, TKDataSourceDataFormat.JSON,
"fridayLotList"
, error =>
{
if
(error !=
null
)
{
Console.WriteLine(
"Can't connect with the server!"
);
return
;
}
dataSource.DisplayKey =
"Inv_Prim_Cat_Desc"
;
listView.WeakDataSource =
this
.dataSource;
listView.ReloadData();
});
}
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
it's working.Thank You. Now will start look into custom cell
I'm happy to hear everything is working for you. If you have any further questions about this specific issue you can reply here.
If you have any trouble or have questions about cells, please open a new thread where the thread title matches the discussion.
Thank you for contacting Support and for choosing Telerik.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress