Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:56:10+00:00 2026-06-14T19:56:10+00:00

My problem I’m pretty positive is simple, I must just be missing something.. just

  • 0

My problem I’m pretty positive is simple, I must just be missing something.. just not sure what.

I can send GET and POST for granular elements (this=that kind of stuff), but a web service call I need to send data too, takes a raw JSON block, with no “key”

Heres the method I wrote:

-(NSData *)execute {

    // Smart Chooser ?
    if(PostData.count >0 || Payload != nil)
        [self setMethod:UPLINK_METHOD_POST];
    else
        [self setMethod:UPLINK_METHOD_GET];



    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.connectionUrl
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
                                                       timeoutInterval:10];


    if([UPLINK_METHOD_GET isEqualToString:self.connectionMethod])
        [request setHTTPMethod:@"GET"];
    else
        [request setHTTPMethod:@"POST"];


    NSString *gData = [self compileGetData];
    NSString *pData = [self compilePostData];

    // if we have get data, set it into the URL string
    if(GetData.count > 0) {

        [self setURLWithString:[[self.connectionUrl absoluteString] stringByAppendingString:[@"?" stringByAppendingString:gData]]];
        [request setURL:self.connectionUrl];

    }

    // if we have post data, set it in the body
    if(PostData.count > 0) {
        const char *bytes = [[NSString stringWithString:pData] UTF8String];
        [request setHTTPBody:[NSData dataWithBytes:bytes length:strlen(bytes)]];

    }

    // Override any post data if a payload is already defined.
    if(Payload != nil) {

        [request setHTTPBody:[Payload dataUsingEncoding:NSUTF8StringEncoding]];

    }

    NSLog(@"URL : %@", request.URL);


    NSURLResponse *response;
    NSError *err;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];

    if(err != nil)
        NSLog(@"here was an error: %@", err);


    return responseData;
}

-(NSDictionary *)executeAsJSON
{
    NSData *responseData = [self execute];
    NSError *e;
    return [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&e];
}

Ok SO, the way this thing works, is that it automatically sets whether the request is POST or GET depending on the data provided in the GetData, PostData, and Payload vars.

The request is GET by default, but turns into POST if PostData or Payload have anything in them.
The compileGetData and compilePostData mostly just bring back formatted strings with arrays of information combined, nothing special there.

But thats not where the problem is.

See, “Payload” overrides anything “PostData” had in it. If you had provided PostData elements into the class, it would just be overridden by a provided Payload if that does exist.

I needed to provide this to demonstrate the “workarea” as it exists right now, its not linearly provided information.

This is the area of interest:

// Override any post data if a payload is already defined.
if(Payload != nil) {

    //const char *plbytes = [[NSString stringWithString:Payload] UTF8String]; // this didn't work
    [request setHTTPBody:[Payload dataUsingEncoding:NSUTF8StringEncoding]]; // inline, doesn't work either

}

When I say “doesnt work”, what I mean is, im getting back an error JSON array from the webservice that basically means “hey, wheres the payload?”. If the request is not POST it comes back as a general error, so thats all working, the URL is then obviously correct.

I’ve used RESTConsole for Chrome to test the webservice to make sure its working properly, and it does.

I’ve also checked through the debugger the exact payload im sending, i copy+pasted that into RESTConsole, and it works there.

I’m.. honestly at a loss here…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:56:12+00:00Added an answer on June 14, 2026 at 7:56 pm

    Try using a web proxy like Charles or Wireshark (I personally preferr Charles due to it’s ease of use, it’s a 30-day trial though) and monitor the request you make from RESTConsole and the one you make from your app and see if they look the same.

    Check any headers, line returns and anything else that looks different.

    That’s the best I can think of to start with

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

?Problem is pretty simple, I extend Button to create ImageButton, and I extend ButtonSkin
Problem: I can set the exposureMode property of AVCaptureDevice, but it does not stay
Problem in short: I'm trying to make a simple show/hide toggle work on just
PRoblem: i'm trying to create (just for fun) a simple poker card (with a
Problem: Been struggling to get my code to load external shaders and it is
Problem: I need to get a random element for a container and also delete
Problem: If user is not logged into GameCenter account - GameCenter authentication view is
Problem is I can see already the value of my json through firebug but
PROBLEM SOLVED. Special thanks to Andrew Noyes for explaining its not a class but
Problem: to combine PATHs with filenames, such that I can easily source many files.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.