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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:35:42+00:00 2026-06-04T18:35:42+00:00

I have a a data object, called DataElement. It contains a string of Base64

  • 0

I have a a data object, called DataElement. It contains a string of Base64 converted image bytes, along with a couple of other fields.

I am trying to post this to my wcf service and am getting an error ‘Expected status code in (200-299), got 400.

The goal is to post data + an image to the WCF (rest) service, and get a modified image back- an end to end test of what I am working on.

In my post method, if I leave the encoded string empty on the object everything works just fine- but if that string is anything other than empty I get this error.

My WCF service isn’t even being hit, it just bombs right to the error. Here is my post method… what am I doing wrong?

- (void)postDataToServer:(NSString*)server dataElement:(DataElement*)dataElement asJson:(BOOL)useJson
{
NSString *urlString = [[NSString alloc] init];
NSData *encodedData;

urlString = [[server copy] stringByAppendingString:@"EchoXml"];
encodedData = [self encodeDataElementAsXml:dataElement];

NSURL *url = [NSURL URLWithString:urlString];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];

NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:urlString parameters:nil];
[request setHTTPBody:encodedData];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    [_responseTextView setText:[NSString stringWithFormat:@"Successfully uploaded file to %@", urlString]];

    NSObject *httpResponseObject;

    httpResponseObject = [self parseResponseAsXml:responseObject];

    if ([httpResponseObject isKindOfClass:[DataElement class]])
    {
        DataElement *dataElement = (DataElement *)httpResponseObject;
        _responseTextView.text = dataElement.DataText;
        if (dataElement.DataImageBase64 != nil)
        {
            UIImage *dataImage = [self getImageFromString:dataElement.DataImageBase64];
            self.responseImageView.image = dataImage;
        }
    }

    NSLog(@"Successfully uploaded file to %@", urlString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    // It goes here immediately
    [_responseTextView setText:[NSString stringWithFormat:@"Error: %@", error]];
    NSLog(@"Error: %@", error);
}];

[operation start];
}

Edit: Sorry the formatting got wonky when I pasted it in…

  • 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-04T18:35:44+00:00Added an answer on June 4, 2026 at 6:35 pm

    I know its bad form to answer my own question- but I found and fixed the problem. Bottom line, the code I was using above is fine- maybe not optimal (as Kurt pointed out) but it does what it is supposed to do.

    The problem was on on my WCF service- REST service requests by default have a 65k upload limit. I reconfigured the service to allow large file uploads and everything is good.

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

Sidebar

Related Questions

I have a Django Queryset object called data containing string keys and float values.
Say I have an object called data which contains a variety of information. Let's
I have a data object -- a custom class called Notification -- that exposes
I have a data model object User . My app also has some other
I have converted an array to object data like this: <?php $myobject->data = (object)Array('zero','one','two');
I have an data transfer object called Report . These report objects are held
I have a core data model object called Entry. In this I have an
I have a nested javascript object called data. Is there any way to iterate
I have a Core Data object called Workshop. It has a to-many relationship to
Say you have a Core Data object called Workshop. It has a to-many relationship

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.