简体   繁体   English

如何到达路径参数字段中包含`:。*`的其余端点

[英]How to hit the rest endpoint that has `:.*` as a part of the path param field

I am using the Stash's REST API in my project. 我在我的项目中使用Stash的REST API。 My task is to get the tag details for a specific tag. 我的任务是获取特定标签的标签详细信息。 After checking the Stash's REST API documentation, I found the correct endpoint that I should be using. 在检查Stash的REST API文档之后,我找到了我应该使用的正确端点。 It is 它是

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}

Please see this link for the Stash's REST API documentation. 请参阅此链接以获取Stash的REST API文档。

There is one more endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags 还有一个端点/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags
With this endpoint I am able to retrieve all the tags. 使用此端点,我可以检索所有标签。 The StashTag object looks something like this. StashTag对象看起来像这样。

  {
    "id": "refs/tags/v4.0.0",
    "displayId": "v4.0.0",
    "latestChangeset": "234dadf41742cfc2a10cadc7c2364438bd8891c5",
    "latestCommit": "234dadf41742cfc2a10cadc7c2278658bd8891c5"
    "hash" : "null"
  }

My first problem is, I don't know which field to use as the parameter for {name:.*} . 我的第一个问题是,我不知道将哪个字段用作{name:.*}的参数。 Should it be the displayId or Id or anything else. 它应该是displayId还是Id或其他任何值。

The second problem is, I don't understand what it means to have : (colon) followed by a . 第二个问题是,我不知道拥有:冒号)后跟一个是什么意思. (dot) in the endpoint /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*} . (点)在端点/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/tags/{name:.*}

Can someone explain me what is the purpose of :. 有人可以向我解释:.的目的是什么:. in the path param and how to hit this kind of an endpoint. 在路径参数中以及如何达到这种终点。 Also an example of the complete endpoint would be nice. 完整端点的一个示例也很好。

So far I have tried hitting 到目前为止,我已经尝试过

https://stashtest.abc.com/rest/api/1.0/projects/KARTIK/repos/kartiks-test-repository/tags/v4.0.0
https://stashtest.abc.com/rest/api/1.0/projects/KARTIK/repos/kartiks-test-repository/tags/refs/tags/v4.0.0  

None of these endpoints work. 这些端点都不起作用。

Any help is appreciated. 任何帮助表示赞赏。

The {name:.*} is really just saying that the field name can be anything. {name:.*}实际上只是在说字段name可以是任何东西。 Chalk this one up to poor documentation on their part. 将此内容整理成糟糕的文档。 Think of it like Regex field, because that's exactly what it is. 可以将其视为正则表达式字段,因为这正是它的本质。 I'm sure at one point they had something like ^[0-9] then went back and changed it when they realized using only tag numbers would omit anyone using their lightweight tag features. 我敢肯定,他们曾经有类似^[0-9]东西,然后回过头来更改它,因为他们意识到仅使用标签号会忽略使用轻量级标签功能的任何人。

Remove the v from your tag version and see if that helps. 从标签版本中删除v ,看看是否有帮助。 If it does not, I would also recommend creating a lightweight tag (something like mytag ) and seeing if you can hit it that way (ie, /kartiks-test-repository/tags/mytag ). 如果没有,我也建议创建一个轻量级标签 (类似于mytag ),然后查看是否可以/kartiks-test-repository/tags/mytag方式进行打标(即/kartiks-test-repository/tags/mytag )。

But looking at that documentation is telling me that your v in your tag name is throwing off the REST call. 但是查看该文档可以告诉我,您的标签名称中的v引发了REST调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM