Karan
Karan

Reputation: 15094

How to specify Restkit object manager to perform a POST

I am trying to send a POST request using ios Restkit. I can perform a GET, but cannot find how to send a POST.

My current code looks like the following:

RKURL *URL = [RKURL URLWithBaseURL:[objectManager baseURL] resourcePath:@"/users/sign_in.json" queryParameters:params];

[objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"%@?%@", [URL resourcePath], [URL query]]  delegate:self];

Apparently, this performs a GET. Any idea what I should add to make it a POST?

Thanks!

Upvotes: 1

Views: 767

Answers (2)

Marco
Marco

Reputation: 6692

You can configure your RKRequest with:

[request setMethod:RKRequestMethodPOST];

Upvotes: 1

Paul de Lange
Paul de Lange

Reputation: 10633

To answer your question (regardless of the above discussion) you can do the following:

[objectManager loadObjectsAtResourcePath: @"path" usingBlock: ^(RKObjectLoader *loader) {
    loader.HTTPMethod = RKRequestMethodPOST;
}];

Upvotes: 0

Related Questions