0
我想通过使用Restclient
宝石的特定URI传递POST方法请求。但是,我不断从服务器获取400 Bad request
。我尝试了多种方式发布数据,并进行了修改。 PFB目前的一个HTTPS:400错误的请求!无效的JSON
require 'minitest'
require 'rest-client'
require 'json'
require 'pry'
require 'uri/https'
#class APITest < Minitest::Test
def setup
response = RestClient.post("", {'userType' => 'nonsso', 'firstName' => 'Justin9', 'isDependentMajor' => true, 'email' => '[email protected]', 'dependentName'=> 'Cobb', 'dependentLastName' => 'Cobb', 'lastName' => 'Justin'
}, { "Content-Type" => 'application/json'})
puts response
end
setup
我不知道我在这里错过了什么。我试着用get方法使用相同的代码,用于其他api,只用headers
,它工作。
请有人让我知道,在我用于POST
方法的json中有任何不好的语法。
我以前尝试过添加'to_json',但它没有奏效。仍然不好的请求和无效的JSON :( –
与你目前的代码也是,我收到了同样的东西。我试图重新检查与帖子的人工具和相同的网址与参数在那里工作 –
工程!我想,我留下的空间数据在这里,我尝试删除这些空间,现在它似乎工作:) –