cybertk / abao

REST API automated testing tool based on RAML
MIT License
354 stars 59 forks source link

Couldn't send url encoded form params #65

Open sprakasam opened 8 years ago

sprakasam commented 8 years ago

The server receives the url encoded form params as single entry with param "key" populated with whole thing mentioned for "test.request.body" in raml file and param "value" as empty string. Like,

key = {"id": "...", "imageType": "...", "imageBase64Encoded": "..."}, value = ""

Note: I don't have any problem with RAML file.

Hookup file: hooks.before('POST /v1/foo -> 200', function (test, done) {

test.request.headers = {
    'Authorization': 'Bearer ' + '77aacdc2-49ea-32cd-8772-e90f3f3e1325',
    'Content-Type': 'application/x-www-form-urlencoded'
};
test.request.body = {
    id: '...',
    imageType: 'image/png',
    imageBase64Encoded: '....'
}

}

plroebuck commented 8 years ago

Think the problem is with your test.request.body -- for application/x-www-form-urlencoded, it should be in the format MyVariableOne=ValueOne&MyVariableTwo=ValueTwo, using percent encoding [wikipedia, blog]. As an aside, usually sending binary files (PNG images) would be done more efficiently using multipart/form-data encoding instead.

plroebuck commented 8 years ago

Hookup file... hilarious! Interweb dating site?