Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hot to post json #107

Open
dmotrenko opened this issue Jun 1, 2016 · 1 comment
Open

hot to post json #107

dmotrenko opened this issue Jun 1, 2016 · 1 comment

Comments

@dmotrenko
Copy link

dmotrenko commented Jun 1, 2016

Given this api http://api.lbs.yandex.net/geolocation

I need to post JSON body (example)

json={
"common": {
"version": "1.0",
"api_key": "AAwkGkwBAAAA9muWLAMAKp9XjTBZtmOLeiBQJqHX6YEqNdUAAAAAAAAAAAAoEP1ZsBlcVFA_OpP55MK3Ek1r8A=="
},
"gsm_cells": [
{
"countrycode": 250,
"operatorid": 99,
"cellid": 42332,
"lac": 36002,
"signal_strength": -80,
"age": 5555
}
],
"wifi_networks": [
{
"mac": "00-1C-F0-E4-BB-F5",
"signal_strength": -88,
"age": 0,
}
,
{
"mac": "00904CC10000",
"signal_strength": -87,
"age": 0,
}
],
"ip": {
"address_v4": "178.247.233.32"
}
}

I can do this in advanced Rest client, but when I try airborne

require 'airborne'
require 'json'
Airborne.configure do |config|
config.base_url = 'http://api.lbs.yandex.net'
config.headers = {'Content-Type' => 'application/json'}, {'accept' => 'application/json'}
end

describe 'geolocation' do

it 'geolocation' do
json = 'json = {
"common": {
"version": "1.0",
"api_key": "AAwkGkwBAAAA9muWLAMAKp9XjTBZtmOLeiBQJqHX6YEqNdUAAAAAAAAAAAAoEP1ZsBlcVFA_OpP55MK3Ek1r8A=="
},
"gsm_cells": [
{
"countrycode": 250,
"operatorid": 99,
"cellid": 42332,
"lac": 36002,
"signal_strength": -80,
"age": 5555
}
],
"wifi_networks": [
{
"mac": "00-1C-F0-E4-BB-F5",
"signal_strength": -88,
"age": 0,
}
,
{
"mac": "00904CC10000",
"signal_strength": -87,
"age": 0,
}
],
"ip": {
"address_v4": "178.247.233.32"
}
}'
post '/geolocation', {'Content-Type' => 'application/json'}, {'accept' => 'application/json'}, json.to_json

end

end

I always get

ArgumentError:
wrong number of arguments (4 for 1..3)

What did I do wrong? How to post json using airborne?

@sethpollack
Copy link
Collaborator

You are passing too many arguments. You have two arguments for headers, merge them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants