0

In my Rails app,I send a post request:

require 'net/http'
url="http://192.168.0.84:809/Services/SDService.asmx/UserRegister"
Net::HTTP.post_form(URI(url),{:memtyp=>'CU',:memid=>'100867',:dob=>'1989-01-01'}).body

But I got the error:

incompatible character encodings: UTF-8 and ASCII-8BIT

I found that the response data include UTF-8 character just like 中文,and then I got this error.

so what should I do?

HXH
  • 1,643
  • 4
  • 19
  • 31
  • possible duplicate of [incompatible character encodings: ASCII-8BIT and UTF-8](http://stackoverflow.com/questions/5286117/incompatible-character-encodings-ascii-8bit-and-utf-8) – Pavan Mar 24 '14 at 07:16

1 Answers1

0

You can send data in json format if you want to do so you can do this by following:

require 'rest_client'
require "net/http"
require "uri"
require 'json'


RestClient.post 'localhost:3001/users',{:memtyp=>'CU',:memid=>'100867',:dob=>'1989-01-01'}.to_json , :content_type => :json, :accept => :json

Plese change the localhost url to actual url you want to hit.

neo-code
  • 1,076
  • 10
  • 26