6

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

Markus
  • 3,948
  • 8
  • 48
  • 64

1 Answers1

11

I got the solution:

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

Markus

Aamir
  • 16,329
  • 10
  • 59
  • 65
Markus
  • 3,948
  • 8
  • 48
  • 64