简体   繁体   English

REST API设计:URL为查询参数时的POST或GET

[英]REST API DESIGN: POST OR GET when a URL is the query parameter

I am writing an API and it will support a query where a URL will be the query term, eg: return the id of a document that has the data {"url":"http://google.com/directory/directory/document/index.html"} 我正在编写一个API,它将支持一个查询,其中URL将作为查询词,例如:返回具有数据{"url":"http://google.com/directory/directory/document/index.html"}的文档的ID。 {"url":"http://google.com/directory/directory/document/index.html"}

the API url would be something like this /document/getid API网址应类似于/document/getid

From my reading GET should be used to do queries but when the query could be very long URL, is that still the best option, I am considering using POST but I want to follow API design best practices. 根据我的阅读,应该使用GET进行查询,但是当查询可能是非常长的URL时,那仍然是最佳选择,我正在考虑使用POST,但我想遵循API设计的最佳做法。

我决定对URL进行md5哈希并将其存储为文档中的字段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM