C# - Обновление Limesurvey до версии 6.6.5 создает проблемы с export_responses API - RPC 2.0C#

Место общения программистов C#
Ответить
Anonymous
 C# - Обновление Limesurvey до версии 6.6.5 создает проблемы с export_responses API - RPC 2.0

Сообщение Anonymous »

Я использовал API LSRC2 JSON/RPC 2.0 для подключения к Limesurvey и экспортировать завершенные опросы с Limesurvey версии 5.3.32 и C# в качестве языка программирования. Я использовал метод API export_responses, и все работало, как и ожидалось. Массив в результате, даже если есть опросы. Основные части кода: < /p>
private readonly JsonRpcClient client;
< /code>
var exportResponsesRequest = new JsonRpcRequest()
{
RequestId = ++requestId,
Method = "export_responses",
Parameters = new Dictionary
{
["sSessionKey"] = sessionKey,
["iSurveyID"] = surveyId,
["sDocumentType"] = "json",
["sLanguageCode"] = language,
["sCompletionStatus"] = completionStatus,
["sHeadingType"] = headingType,
["sResponseType"] = responseType,
["iFromResponseID"] = fromResponseID,
["iToResponseID"] = toResponseID
},
};
var response = await client.PostAsync(exportResponsesRequest);
try
{
return DecodeBase64(response.Result?.ToString());
}
catch
{
// If string isn't base64, it likely contains an error message.
}
< /code>
The PostAsync function in JsonRcpClient class is as follow:
public async Task PostAsync(JsonRpcRequest requestObject)
{
var httpClient = new HttpClient();
string requestJson = JsonSerializer.Serialize(requestObject);
var stringContent = new StringContent(requestJson, Encoding.UTF8, "application/json");
var httpResponse = await httpClient.PostAsync(url, stringContent);
var resultString = await httpResponse.Content.ReadAsStringAsync();
return ProcessResponseObject(resultString, httpResponse.StatusCode, requestObject);
}
< /code>
And the class JsonRcpResponse is as follow:
public class JsonRpcResponse
{
[JsonPropertyName("id")]
public int Id { get; set; }

[JsonPropertyName("result")]
public object Result { get; set; }

[JsonPropertyName("error")]
public string Error { get; set; }

public HttpStatusCode StatusCode { get; set; }
}
< /code>
Notice that I have the correct result with the same configuration running on postman.
I tried all possible changes that I found online, but I couldn’t resolve the issue.
I tried Upgrading LimeSurvey from version 5.3.32 to version 6.6.5 and the code that calls LimeSurvey API stopped working. I stepped through the code and I found out that the export_responses API always returns an empty array as a JSON response, even if there were completed surveys to export.
The same method in Postman returned the correct array of responses using LimeSurvey version 6.6.5.
When reverting the LimeSurvey to the previous version (5.3.32) without any change of the code, the API resumed working as expected.
Could you please help me figure out what the issue is.
Thanks for your answer.

Подробнее здесь: https://stackoverflow.com/questions/793 ... ort-respon
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»