1

I've got an issue with posting an array of strings to the server:

My Mapping is this:

+(RKMapping*)occurrenceCreateMapping {

    RKObjectMapping *occurrenceCreateMapping = [RKObjectMapping requestMapping];

    [occurrenceCreateMapping addAttributeMappingsFromDictionary:@{
     @"observedOn" :@"ObservedOn",
     @"latitude" :@"Latitude",
     @"longitude" :@"Longitude",
     @"address" :@"Address",
     @"host" :@"Host",
     @"pests" : @"Pests",
     @"networkId" :@"NetworkId",
     @"consignmentNumber" :@"ConsignmentNumber"
     }];

    return occurrenceCreateMapping;
}

But what is actually getting posted is this:

Post from Charles proxy

Which is invalid because my server side model binder is expecting a single array of strings.

This is the code for my OccurrenceCreate Class:

@interface BBOccurrenceCreate : NSObject

@property (nonatomic, retain) NSDate *observedOn;

@property CGPoint location;

@property (nonatomic, retain) NSString  *latitude,
                                        *longitude,
                                        *address,
                                        *host,
                                        *consignmentNumber,
                                        *networkId;

@property (nonatomic,retain) NSArray *pests;

@end

Can anyone help me map this array of strings to a json array? I'm thinking this should be simple ?!?!

4
  • Can't remember the correct fix, do you need to add forceCollectionMapping? Commented Sep 25, 2013 at 12:28
  • That looks familiar to me too, but it doesn't work Commented Sep 25, 2013 at 14:49
  • 1
    Are you explicitly setting the serialisation type (and what type do you intend)? Commented Sep 25, 2013 at 15:06
  • That was it Wain - if you can put that in as an answer, I can give you a tick. Cheers mate. Commented Sep 26, 2013 at 0:15

1 Answer 1

1

You're probably missing the serialisation type setting so RestKit is defaulting to form-url-encoded. Explicitly set the serialisation type to instruct RestKit to generate JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.