1
votes

when I send request to the API below, the response is

Bad Request, the request cannot be fulfilled due to bad syntax.

Why do I get this response?

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/import%20requests/create?view=azure-devops-server-rest-5.0#gitimportrequestparameters

POST https://{instance}/{collection}/{project}/_apis/git/repositories/{repositoryId}/importRequests?api-version=5.0-preview.1

I used bodies below; (i created endpoint)

a)

{
   "parameters":{
      "deleteServiceEndpointAfterImportIsDone":true,
      "gitSource":{
{
            "url":"bitbucketurl",
            "overwrite":false
         }
      },
      "tfvcSource":null,
      "serviceEndpointId":"{1}"

   }
}

b)

{
    "deleteServiceEndpointAfterImportIsDone": true,
    "parameters": {
        "gitSource": {
            "url": "bitbucketurl"
        },
        "tfvcSource": null,
        "serviceEndpointId": "01bfbasdadsadasd"
    }
}

c) this one is given by azure devops docs.

{
  "parameters": {
    "gitSource": {
      "url": "https://github.com/Microsoft/vsts-agent.git"
    }
  }
}
1
And sometimes i got this response too, { "$id": "1", "innerException": null, "message": "Value cannot be null.\r\nParameter name: importRequest", "typeName": "System.ArgumentNullException, mscorlib", "typeKey": "ArgumentNullException", "errorCode": 0, "eventId": 0 }user12600814
As per Body A - it contains invalid JSON hence "bad syntax" error is thrown. You can check it here onlinejsontools.com/validate-jsonNikolai Shevchenko

1 Answers

0
votes

According to your issue, I have conducted many tests and at first I got the same error as you:

enter image description here

Later I tested the Azure devops and tfs2018 rest api and they were successful. When I tested the azure devops server2019 api again, it worked successfully, so this should not be a bug, you can try a few more times.

enter image description here