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 8393981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:56:48+00:00 2026-06-09T19:56:48+00:00

I have the following code: NSString *post = @i hope this gets there; NSData

  • 0

I have the following code:

NSString *post = @"i hope this gets there";

NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
NSString *postLength = [NSString stringWithFormat:@"%d", [post length]];

NSURL *url = [NSURL URLWithString:@"http://www.oneoftwosites.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];

[NSURLConnection connectionWithRequest:request delegate:nil];

//potential response
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

//convert response so that it can be LOG'd
NSString *returnString = [[NSString alloc] initWithData:response encoding:NSASCIIStringEncoding];

NSLog(@"RETURN: %@", returnString);

I have tested it with 2 different websites: http://www.htmlcodetutorial.com/cgi-bin/mycgi.pl and http://instagraph.me/post, by substituting those urls in for http://www.oneoftwosites.com. For some reason, it only works with the first website (which is written in perl), and not with the second (which is written in .php).

Does anyone have any ideas why this might be? It seems dumb that it would only work sometimes, but I don’t really have any idea why it doesn’t work for the second website (I haven’t seen the code but I did see some sample output).


EDIT: I added

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; and tried a couple different types but still no luck

  • 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-09T19:56:50+00:00Added an answer on June 9, 2026 at 7:56 pm

    What kind of POST data does Instagraph expect? Chances are, it’s some kind of structured data, like a URL encoded form, or XML, or JSON. Your string is neither of those. So provide a Content-Type, and format your POST data accordingly. Maybe you’ll get better luck then.

    EDIT: Your second site is Instagraph. It’s a public website. It probably has a documented API – what fields and values should there be in a POST. Is the POST data that you’re sending up to that spec? So far, I don’t think so. If you sending dummy, test data – why are you expecting it to work? What sensible effect are you expecting?

    The line “i hope this gets there” does not, by the way, constitute a valid data block of type application/x-www-form-urlencoded.

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

Sidebar

Related Questions

I have the following code hostStr = [hostStr stringByAppendingString:post]; NSData *dataURL = [NSData dataWithContentsOfURL:
I have gone through this question that shows the following code: -(NSString *)tableView:(UITableView *)tableView
I have the following code used to post data to a remote server: NSString
I have the following code: NSString *indexText = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; if (indexText==nil)
I have the following code: .h NSString *mainString; .m case 0: case 1: case
I have the following code to open google maps: NSString *urlString = [NSString stringWithFormat:@http://maps.google.com/maps?q=%@,
Hello I have the following code: if(_deviceSegmentCntrl.selectedSegmentIndex == 0) { deviceOne = [[NSString alloc]
I Have the following code: -(void) changeAnimation:(NSString*)name forTime:(int) times { if(currentAnimation != @attack) {
I have the following code: NSString *subtitle = [[[node elementsForName:@subtitle] objectAtIndex:0] stringValue]; NSString *duration
I have the following code: NSString *text = @http://bit.ly/111 http://bit.ly/222 http://www.www.www; NSRegularExpression *aLinkRegex =

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.