看似简单的事情却导致了我的错误
我在我的帖子中添加了一个自定义标头到 webapi aspnetcore 2.1 端点,但是当标头添加到请求中时,我在邮递员中得到了这个
Could not get any response
There was an error connecting to http://localhost:3481/api/account/register.
当我删除标题时,它按预期工作。
自定义标题是CorrelationId这是帖子
POST //api/account/register HTTP/1.1
Host: localhost:3481
Content-Type: application/json
CorrelationId: 0bdf0a56-fe94-479c-a6db-4b93ad81ad6c
Cache-Control: no-cache
Postman-Token: 7324c922-2911-4ac4-9ede-6401199f4f87
{
"firstName": "dev 23",
"lastName": "dev",
"username": "devuser23",
"email": "devuser23@dev.com",
"phoneNumber": "6468842757",
"password": "!Password1",
"confirmPassword": "!Password1",
"OneSignalUserId":"teststring",
"PushToken":"anotherteststring",
"Roles":["Customer"]
}
我不确定它的标题有什么问题。
我检查了日志和应用程序见解,它们甚至没有显示正在发出的请求或引发任何异常。
编辑 我回去查看邮递员中的值的输入框,它确实有返回,这导致了额外的行。下面是我删除空间后的样子。
POST //api/account/register HTTP/1.1
Host: localhost:3481
Content-Type: application/json
TableTopCorrelationId: 0bdf0a56-fe94-479c-a6db-4b93ad81ad6c
Cache-Control: no-cache
Postman-Token: 12a4c705-9658-412f-bfd2-5df75d4b0d70
{
"firstName": "dev 23",
"lastName": "dev",
"username": "devuser23",
"email": "devuser23@dev.com",
"phoneNumber": "6468842757",
"password": "!Password1",
"confirmPassword": "!Password1",
"OneSignalUserId":"teststring",
"PushToken":"anotherteststring",
"Roles":["Customer"]
}
现在可以使用了,谢谢。