休息,使用Get作为查询字符串发送参数或只使用Post获取信息

时间:2017-05-24 11:45:58

标签: java rest architecture

我需要公开Rest API,它根据E/SearchServiceStarter: Task 174 failed or timed out. Client 75449983474519810 disconnecting from SearchService! java.util.concurrent.CancellationException: Task was cancelled. at com.google.common.util.concurrent.d.ct(SourceFile:75) at com.google.common.util.concurrent.d.get(SourceFile:57) at com.google.common.util.concurrent.cg.n(SourceFile:2) at com.google.common.util.concurrent.av.l(SourceFile:50) at com.google.common.util.concurrent.ax.run(SourceFile:5) at com.google.android.apps.gsa.shared.util.concurrent.a.bc.run(SourceFile:2) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 检索有关Brand的信息, 所以我需要发送brandId参数。 从Rest Architecture and Design的角度来看,我应该使用brandId(使用正文中的参数),还是使用Post并将参数作为查询字符串或标题发送

2 个答案:

答案 0 :(得分:1)

你应该使用GET。 POST用于将一些新信息放入或更新到服务/数据库中。

尝试阅读:What is the difference between POST and GET?

而且:When should I use GET or POST method? What's the difference between them?

答案 1 :(得分:0)

我使用了GET,并将参数brandId作为路径变量

发送