1.postman测试web服务时添加json类型的参数
通常我们看到的使用情境多数是直接呼叫Web API而未随着Request发送相关所需参数,Web API时一并夹带JSON数据时,该如何使用Postman?
情境假设 :
采用POST的请求方式,并且须夹带JSON数据给Web API
使用方式 :
(1) 输入Web API 地址,并选择以POST方式发送
(2) 点选 Headers按钮 ,加入宣告Content-Type是以JSON传送 ( Headers 输入 Content-Type , Value 输入 application/json ),这个设定步骤是个关键
(3) 接着点选 raw ,并设定为JSON
data(){
return{
form: {
name: '',
individualitySignature: '',
introduce: '',
}
}
},
methods: {
onSubmit: function(){
this.$http.post('/api/save/personalInformation', {
form: this.form
}).then(
respone => this.$message('保存成功'),
respone => this.$message.error('保存失败,请刷新页面重试')
)
}
}