For new issue GitLab Api has a cURL example:
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug"
I'm using HttpRequestMessage method like this:
static async Task<Issue> new_issue(string repository, int appId, string issueTitle, string issueDescription, int assignee_ids) //New ISSUE
{
string issue_path = which_repo(repository)[0] + "projects/" + appId + "/issues/" + "?title=" + issueTitle + "&description=" + issueDescription + "&assignee_ids=" + assignee_ids;
using (var request = new HttpRequestMessage(new HttpMethod("POST"), issue_path))
{
request.Headers.TryAddWithoutValidation("PRIVATE-TOKEN", which_repo(repository)[1]);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
Issue new_issue = JsonConvert.DeserializeObject<Issue>(content);
Console.WriteLine("Utworzono issue:"+Environment.NewLine+"Tytuł:"+new_issue.title+Environment.NewLine+"Opis:"+new_issue.description+Environment.NewLine+"Assignee:"+new_issue.assignee.name);
return new_issue;
}
}
For new projects there is cURL like this:
curl --request POST --header "PRIVATE-TOKEN: <your-token>" \
--header "Content-Type: application/json" --data '{
"name": "new_project", "description": "New Project", "path": "new_project",
"namespace_id": "42", "initialize_with_readme": "true"}' \
--url 'https://gitlab.example.com/api/v4/projects/'
How to do it with HttpRequestMessage??