Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send json object with httparty

I'm trying to implement the in App purchase from within my iPhone app. To verify the receipt I need to send a json object to the iTunes server. Im trying to do this with the httparty plugin:

require 'httparty'

class ItunesVerification
  include HTTParty
  base_uri 'https://sandbox.itunes.apple.com'
  default_params :output => 'json'
  format :json
end


@result = ItunesVerification.post('/verifyReceipt', :query => {'receipt-data' => params[:receipt]})

When I do so, I keep getting a...

{"status":21002, "exception":"java.lang.NullPointerException"}

... error. I guess this is because of the not right implementation of the json object. The Object should have the structure: { "receipt-data" : "...." }... because of the - character in receipt-data it dosn't accept as :receipt-data identifyer...

How do I have to implement that right?

Thanks Maechi

like image 245
Markus Avatar asked Jul 27 '10 08:07

Markus


1 Answers

I got the solution:

I have to write :body instead of :query! Then it gets sent as a json object!

Markus

like image 165
Markus Avatar answered Oct 20 '22 09:10

Markus