API POST API causes problems with JSON corpus

I am trying to connect to the API and I keep getting wrong saying that I am not including the client_id in the call. Here's the code:

+ (void)connectWithUsername:(NSString *)username Password:(NSString *)password Type:(NSString *)type Email:(NSString *)email
{
    NSString *urlString = [kTestAPI stringByAppendingString:@"connect"];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];

    NSDictionary *params = @{@"client_id":client,
                         @"secret":secret,
                         @"credentials":@{@"username":username,@"password":password},
                         @"type":type,
                         @"email":email};
    NSLog(@"PARAMS: %@", params);
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil];
    request.HTTPMethod = @"POST";
    request.HTTPBody = jsonData;

    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[NSOperationQueue mainQueue]
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
     {
         NSDictionary *output = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
         NSLog(@"SUCCESS: %@", output);
     }];
}

      

Here's the output:

2014-08-23 11:52:53.131 Balance[11538:60b] PARAMS: {
    "client_id" = "test_id";
    credentials =     {
        password = "plaid_good";
        username = "plaid_test";
    };
    email = "test@plaid.com";
    secret = "test_secret";
    type = wells;
}

2014-08-23 11:52:53.554 Balance[11538:60b] SUCCESS: {
    code = 1100;
    message = "client_id missing";
    resolve = "Include your Client ID so we know who you are.";
}

      

At first I thought it might be because the client_id appears in quotes when I NSLog, but after doing some search I found that it appears to be just a description method function that is being called from NSLog as client_id has underscore so that it doesn't count as alphanumeric, so quotes are added, so I don't think it won't affect the JSON. So yes, I'm stumped, any help would be appreciated :)

+3


source to share


1 answer


Job: curl -X POST tartan.plaid.com/connect \ -d client_id=test_id \ -d secret=test_secret \ -d credentials='{ "username":"plaid_test", "password":"plaid_good"}' \ -d type=wells \ -d email=test@plaid.com

Please note that the working helix client_id

, secret

, type

and email

are not part of the json, but some elements of the POST. The JSOM element credentials

has two elements: username

and password

.



You need to do the same in your code.
client_id

, secret

, type

, email

And credentials

are variable POST. 'credentials' has a JSON string as value.

+3


source







All Articles