基本网址:https://api.dialogflow.com/v1/
删除' https://api.dialogflow.com/v1/contexts?sessionId=12345'
接头: 授权:持票人YOUR_CLIENT_ACCESS_TOKEN Content-Type:application / json
我正在使用改装2,我想对Dialogflow发出删除请求。我想删除所有上下文。
这是迄今为止所做的:
@DELETE("contexts?sessionId=12345") Call<Void>deletDialogflow(@Header("Content-Type")String content_type, @Header("Authorization")String auth);
在api电话中。
private void deleteContextDialogFlow(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(DialogflowService.BASE_URL_DIALOGFLOW)
.addConverterFactory(GsonConverterFactory.create())
.build();
DialogflowService service = retrofit.create(DialogflowService.class);
Call call = service.deletDialogflow("application/json; charset=utf-8", DialogflowService.BEARER + DialogflowService.TOKEN_DIALOGFLOW);
call.enqueue(new Callback() {
@Override
public void onResponse(Call call, Response response) {
Log.e("Successful Delete", "" + response.body().toString());
}
@Override
public void onFailure(Call call, Throwable t) {
Log.e("UnSuccessful Delete", "" + t.getMessage());
}
});
}
我没有得到我想要的结果。也就是说,所有情境都会消失。
答案 0 :(得分:0)
请仔细查看我的代码:
<强> DialogflowService.java 强>
@Headers("Content-Type:application/json")
@DELETE("contexts?sessionId=12345")
Call<String> deletDialogflow(@Header("Authorization") String auth);
<强> deleteContextDialogFlow()强>
Call<String> call = service.deletDialogflow(DialogflowService.BEARER+DialogflowService.TOKEN_DIALOGFLOW);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
if (response.isSuccessful()) {
Log.e("Successful Delete", "" + response.body().toString());
}
else{
Log.e("Fail Delete", "" + response.errorBody().string());
}
}
@Override
public void onFailure(Call<String> call, Throwable t) {
Log.e("UnSuccessful Delete", "" + t.getMessage());
}
});