Retrive data by using cloud APIs

Hi

I have set of Estimote beacons and I want to list them using Estimote clound APIs.I am using
curl -u API_USERNAME:API_PASSWORD “https://cloud.estimote.com/v2/analytics/visits/total?group_by=location

It works well in the terminal.
However, in the ios app, it is returning ----“Payment Required”.

The code is following:

#define API_USERNAME      @"xxxxxxx"
#define API_PASSWORD      @"xxxxxxx"

    NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"http://%@:%@@cloud.estimote.com/v2/analytics/visits/total?group_by=location", API_USERNAME, API_PASSWORD]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    
    [request setURL:url];
    [request setHTTPMethod:@"GET"];
    [request setValue:@"Accept: application/json" forHTTPHeaderField:@"Content-Type"];
    
    
    NSError *error;
    NSURLResponse *response;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    NSLog(@"ret=%@", ret);

Thanks for helping.

Cheers,
Larina

Email us at contact@estimote.com, and we’ll look into it.

Hey guys :slight_smile:

is there any update on this issue?
I’m having the exact same problem here (only that I’m working with Swift rather than Objective-C). The Curl command works fine in the terminal, but my iOS App only receives a 402 (payment required).

This is my code:

guard let url = URL(string: "https://ESTIMOTE_APP_ID:ESTIMOTE_APP_TOKEN@cloud.estimote.com/v2/analytics/visits/total?group_by=location?from=1525654800&to=1527181200&granularity=daily") else {return}
    var request = URLRequest(url: url)
    request.httpMethod = "GET"

    // set up the session
    let config = URLSessionConfiguration.default
    let session = URLSession(configuration: config)
    
    // make the request
    let task = session.dataTask(with: request) {
        (data, response, error) in
        // check for any errors
        guard error == nil else {
            print(error!)
            return
        }
        print("Response code: ", response) //--> gives 402 Error
        ...

Any hints are welcoome! Thanks a lot!