ruby on rails - 406 when uploading image from RestKit to RoR backend -
i'm having serious problem , searched many hours without finding solution.
i have backend server using ruby of rails , paperclip image saving.
the image upload works fine browser, posting /pictures
but when try upload /pictures.json using multipart request restkit (ios), 406.
when image (picture object) created server-side, reward (reward object) associated it. reward object i'm expecting json response.
here objective-c code:
nsmutableurlrequest* uploadrequest = [self.objectmanager multipartformrequestwithobject:nil method:rkrequestmethodpost path:@"/pictures.json" parameters:nil constructingbodywithblock:^(id<afmultipartformdata> formdata) { [formdata appendpartwithfiledata:uiimagepngrepresentation(socialreward.image) name:@"picture[pict]" filename:imagename mimetype:@"image/png"]; }];
here controller:
@picture = picture.create( params[:picture] ) respond_to |format| format.html { redirect_to @picture.reward } format.js { render :json => @picture.reward.to_json(:include => :picture) } end
the csrf check disabled.
when comparing requests browser , ios using wireshark, extremely similar.
thanks in advance help.
the problem ror, in respond_to
should using format.json
, not format.js
.
Comments
Post a Comment