1

I am occasionally receiving a bad request error message when making API requests via YouTrackSharp. This only happens when running on the server, if I debug the app locally (running on IIS, not IIS Express), it goes through appropriately. Has anyone experienced this behavior before, and any suggestions?

Exception

YouTrackSharp.Infrastructure.InvalidRequestException: Bad Request ---> EasyHttp.Infrastructure.HttpException: BadRequest Bad Request
   at EasyHttp.Http.HttpClient.ProcessRequest(String filename)
   at YouTrackSharp.Infrastructure.Connection.MakePostRequest(String command, Object data, String accept)
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at YouTrackSharp.Issues.IssueManagement.ApplyCommand(String issueId, String command, String comment, Boolean disableNotifications, String runAs)

Calling Code

issueManagement.ApplyCommand(issue.Id,
  string.Format("Ready For Testing Versions {0}", version),
  string.Format("Marked Ready for Testing for {0} build, compiled {1}, by {2}",
  version, utcDate.ToLocalTime(), user.UserName),
  true);

public void ApplyCommand(string issueId, string command, string comment, bool disableNotifications = false, string runAs = "")
{
    if (!_connection.IsAuthenticated)
    {
        throw new InvalidRequestException(Language.YouTrackClient_CreateIssue_Not_Logged_In);
    }

    try
    {
        dynamic commandMessage = new ExpandoObject();


        commandMessage.command = command;
        commandMessage.comment = comment;
        if (disableNotifications)
            commandMessage.disableNotifications = disableNotifications;
        if (!string.IsNullOrWhiteSpace(runAs))
            commandMessage.runAs = runAs;

        _connection.Post(string.Format("issue/{0}/execute", issueId), commandMessage);
    }
    catch (HttpException httpException)
    {
        throw new InvalidRequestException(httpException.StatusDescription, httpException);
    }
}
4

1 回答 1

0

问题最终成为 YouTrack API 执行我正在使用的命令的一种奇怪方式。我发生在 YouTrack 日志中,并且错误被记录在那里。明智的话:当您看到此错误消息时,请检查 YouTrack 日志。

于 2014-09-03T14:23:13.117 回答