You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TFS本地部署环境下Code Search REST API返回404求助

Troubleshooting TFS 2018 Code Search API 404 Error

Let’s work through this 404 issue with your TFS 2018 Code Search API step by step—here are the most likely fixes to check:

1. Adjust Your API Endpoint Path

TFS 2018’s Code Search API is scoped to the collection level, not individual projects. Your current URL includes a project segment, which is likely causing the 404. Try removing /{Project} from your endpoint:

POST http://{DNS}:8080/tfs/{Collection}/_apis/search/codesearchresults?api-version=4.1-preview.1

You can still target your specific project by adding the projectNames parameter to your request body (e.g., "projectNames": ["YourProjectName"]).

2. Validate API Version Compatibility

Your TFS 2018 version (16.122.27409.2) corresponds to TFS 2018 Update 3. While 4.1-preview.1 is technically supported, preview API versions can have subtle inconsistencies across updates. If adjusting the path doesn’t work, try falling back to api-version=4.0-preview.1—it’s more reliably supported for TFS 2018.

3. Confirm Extension Installation Scope

Even if the Code Search extension works in the portal, ensure it’s installed at the collection level (not just the project level):

  • Go to your collection settings > Extensions > Manage extensions.
  • Locate the Code Search extension and verify it’s enabled for the entire collection. Project-only installations won’t expose the full API endpoints.

4. Check the Underlying Code Search Service

The portal might show the extension as active even if the backend search service isn’t running. In your TFS Administration Console:

  • Navigate to Application Tier > Search service.
  • Ensure the service status is "Running". If it’s stopped, start it and wait 5-10 minutes for it to fully initialize—this is a common oversight that causes API failures.

5. Review Request Body and Permissions

  • Request Body: Make sure your POST request includes a valid minimal body (e.g., {"searchText": "test", "$skip": 0, "$top": 10}). Older TFS versions sometimes return 404 instead of 400 for missing or malformed request bodies.
  • Permissions: Confirm the account calling the API has both View code permission on your project and Use code search permission (under collection-level permissions > Search). While 403 is the usual permission error, misconfigured permissions can occasionally trigger 404s in TFS 2018.

内容的提问来源于stack exchange,提问作者PrimeNum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:59:57