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

  • SEARCH
  • Home
  • 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 8873709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:31:58+00:00 2026-06-14T18:31:58+00:00

my URL is correct, but my request must be malformed. I’m getting a 400.

  • 0

my URL is correct, but my request must be malformed. I’m getting a 400. Any ideas? The API documentation says it could return a 400 if parameters were passed instead of JSON body. Thanks in advance.

- (void)postFeedItem:(NSDictionary *)paramDict Response:(void (^)(id))callbackBlock Failure:(void (^)())failure {

NSString *targetUrl = [NSString stringWithFormat:@"%@/services/data/v23.0/chatter/feeds/user-profile/%@/", _appManager.coordinator.credentials.instanceUrl, [_appManager.userInformation objectForKey:@"sfUserId"]];

AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:targetUrl]];
/*
 { "body" :
 {
 Request body example:
 "messageSegments" : [
 {
 "type": "Text",
 "text" : "New post"
 }
 ]
 }
 }
 */

NSArray *arr = [NSArray arrayWithObjects:
                [NSDictionary dictionaryWithObjectsAndKeys:@"Text", @"type",
                 @"New post", @"text",
                 nil],
                nil];
NSDictionary* info = [NSDictionary dictionaryWithObjectsAndKeys:
                      [NSDictionary dictionaryWithObjectsAndKeys:arr, @"messageSegments", nil],
                      @"body",
                      nil];

NSLog(@"JSON: %@", [[NSString alloc] initWithData:[self toJSON:info] encoding:NSUTF8StringEncoding]);

NSMutableURLRequest *request = [client multipartFormRequestWithMethod:@"POST" path:@"feed-items" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
    [formData appendData:[self toJSON:info]];
}];

[request setValue:[NSString stringWithFormat:@"OAuth %@",_appManager.coordinator.credentials.accessToken] forHTTPHeaderField:@"Authorization"];
[request addValue:@"false" forHTTPHeaderField:@"X-Chatter-Entity-Encoding"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@"success");
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@"FAILED CHATTER Request: %@ - %@ - %@", [request URL], [request allHTTPHeaderFields], error.description);
}];

[operation start];

}

Here’s the NSLog:

2012-09-19 18:10:54.732 RingDNA Free[6018:c07] __47-[ChatterHelper postFeedItem:Response:Failure:]_block_invoke_087 [Line 76] FAILED CHATTER Request: https://na4.salesforce.com/services/data/v23.0/chatter/feeds/user-profile/00560000001j3paAAA/feed-items – {
“Accept-Encoding” = gzip;
“Accept-Language” = “en, fr, de, ja, nl, it, es, pt, pt-PT, da, fi, nb, sv, ko, zh-Hans, zh-Hant, ru, pl, tr, uk, ar, hr, cs, el, he, ro, sk, th, id, ms, en-GB, ca, hu, vi, en-us;q=0.8”;
Authorization = “OAuth 00D60000000KV29!ARkAQFWhnhOtcGFgVMT4MkZHCV3zG9SY4en66718BiG_ZY59W0gR1iSWA8i.ey_b94vqjRW_RQITALBWmfpPrKTGk”;
“Content-Type” = “multipart/form-data; boundary=Boundary+0xAbCdEfGbOuNdArY,application/json”;
“User-Agent” = “com.ringdna.dreamforce.RingDNA-Free/36 (unknown, iPhone OS 5.1, iPad Simulator, Scale/1.000000)”;
“X-Chatter-Entity-Encoding” = false;
} – Error Domain=com.alamofire.networking.error Code=-1011 “Expected status code [number of indexes: 100 (in 1 ranges), indexes: (200-299)], got 400” UserInfo=0xa2a8b40 {NSErrorFailingURLKey=https://na4.salesforce.com/services/data/v23.0/chatter/feeds/user-profile/00560000001j3paAAA/feed-items, NSLocalizedDescription=Expected status code [number of indexes: 100 (in 1 ranges), indexes: (200-299)], got 400}

  • 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-14T18:31:59+00:00Added an answer on June 14, 2026 at 6:31 pm

    We figured this out after a few attempts. Basically SFDC validates the order of the parameters you’re sending to the Chatter APIs, it appears. Code samples for working Chatter posts are in Github now if this helps anyone else:

    https://github.com/kyleroche/Dreamforce-2012

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

Sidebar

Related Questions

I need to redirect non-www to www, with correct URL params. A lot of
How can i deal with correct base url with wrong parameter? Cakephp if u
What would be the correct way to create a fully URL-encoded file:// URI from
How do you redirect a request in ASP.NET MVC to its correct canonical version
My application simply request the json data from url and displays it in TableLayout
I'm firing an HTTP POST request with Ajax to my php file, but I
in VBA i am creating a URL: URL = http://api.local.yahoo.com/MapsService/V1/geocode?appid= & yahoo & &street=
I am using YUI3 to do a GET request, but the event handlers aren't
I have issue with a strange url request to my site.. that may come
I can enter via web http://localhost:8080/tfs/web with any user, from remote or local, but

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.