这是我的代码片段:
UnityWebRequest request=new UnityWebRequest(endpoint,"POST");
request.SetRequestHeader("Content-Type","application/json");
request.SetRequestHeader("host",host);
request.SetRequestHeader("X-Amz-Date",dateTime);
request.SetRequestHeader("Authorization",authorizationHeader);
request.uploadHandler=(UploadHandler)new
UploadHandlerRaw(Encoding.UTF8.GetBytes(requestParameter));
request.chunkedTransfer=false;
request.downloadHandler=new DownloadHandlerBuffer();
request.SendWebRequest();
print(request.downloadHandler.text);
请告知我在这里做错了什么.....
答案 0 :(得分:2)
您需要等待结果下载后才能对其进行任何操作。 Web请求是异步的!
通常,您会使用协同程序来执行此操作,例如
public IEnumerator LoadData()
{
// ......
// all your code goes here, up to the SendWebRequest line
// then you yield to wait for the request to return
yield return request.SendWebRequest();
// after this, you will have a result
print(request.downloadHandler.text);
}
像这样启动协程:
StartCoroutine(LoadData());
此问题的答案中的更多示例:Sending http requests in C# with Unity
答案 1 :(得分:0)
正如frankhermes所说,您需要先等待结果下载,然后再执行任何操作
max()
但是,仅上述一行对我不起作用。
=QUERY(
$A$1:$H$7,
"select H where A = date '"& TEXT(
Query(
$A$2:$H$7,
"select max(A) where B = "&A11&" label max(A) ''",
1
),
"yyyy-MM-dd")&"'",
0
)