域名
訪問TPP服務的地址。
VPC域名,可以在用戶購買實例時,選擇的VPC訪問。
公網域名,暫不支持。
HTTP GET訪問
http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&userId=&yourRequestParam=
shell curl
curl -i "http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam="
Java
OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
.url("http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=")
.method("GET",null)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
JS
var myHeaders = new Headers();
var urlencoded = new URLSearchParams();
var requestOptions = {
method: 'GET',
headers: myHeaders,
body: urlencoded};
fetch("http://${domain}/recommend?_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
HTTP POST訪問
url
http://${domain}/recommend?
header
"Content-Type:application/x-www-form-urlencoded"
body
_instance_cluster=${instanceId}&appid=${sceneId}
shell curl
curl --location --request POST 'http://${domain}/recommend' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode '_input_charset=UTF-8' \
--data-urlencode '_output_charset=UTF-8' \
--data-urlencode '_instance_cluster=${instanceId}' \
--data-urlencode 'appid=${sceneId}' \
--data-urlencode 'yourRequestParam=${yourRequestParam}'
Java
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "_input_charset=UTF-8&_output_charset=UTF-8&_instance_cluster=${instanceId}&appid=${sceneId}&yourRequestParam=${yourRequestParam}");
Request request = new Request.Builder()
.url("http://${domain}/recommend?")
.method("POST", body)
.addHeader("Content-Type", "application/x-www-form-urlencoded")
.build();
Response response = client.newCall(request).execute();
JS
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("_input_charset", "UTF-8");
urlencoded.append("_output_charset", "UTF-8");
urlencoded.append("_instance_cluster", "${instanceId}");
urlencoded.append("appid", "${sceneId}");
urlencoded.append("yourRequestParam", "${yourRequestParam}");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("http://${domain}/recommend", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
文檔內容是否對您有幫助?