簡體   English   中英

如何使Rails API能夠接受json參數而不是http

[英]How to make rails API able to accept json params instead of http

通用Rails API使用jbuilder呈現結果。

用於將數據發送到Rails API服務器的http參數,如下所示:

POST user_id=10&post[0][msg]=text&post[1][post_id]=15&post[1][msg]=message

如何使API能夠接受json入站參數而不是http,如下所示:

POST {user_id:10,post:[{msg:'text'},{post_id:15,msg:'message'}]}

根據@Julia的評論,此問題已關閉。

答案是:傳遞content-type HEADER。 (或在Rails中,在網址末尾使用.json

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM