View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
09402Bug reportsRemoteControlpublic2015-05-08 15:05
Reporterquarrier Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionunable to reproduce 
Product Version2.05+ 
Summary09402: GetResponse error 500 by add_survey from RemoteControl_2_API
Description

I try to use add_survey method but get exception "GetResponse" with "0" arguments: "Remote server return error: (500) internal server error."
used client MS PowerShell
API interface is XML-RPC

Steps To Reproduce

create powershell script with next text:
clear

Function PostWebRequest{
param(
[String]$url,
[String]$data,
[int]$timeout=300000)

$buffer = [System.Text.Encoding]::UTF8.GetBytes($data)
[System.Net.HttpWebRequest] $webRequest = [System.Net.WebRequest]::Create($url)
$webRequest.Timeout = $timeout
$webRequest.Method = "POST"
$webRequest.ContentType = "application/x-www-form-urlencoded"
$webRequest.ContentLength = $buffer.Length;

$requestStream = $webRequest.GetRequestStream()
$requestStream.Write($buffer, 0, $buffer.Length)
$requestStream.Flush()
$requestStream.Close()

[System.Net.HttpWebResponse] $webResponse = $webRequest.GetResponse()
$streamReader = New-Object System.IO.StreamReader($webResponse.GetResponseStream())
$result = $streamReader.ReadToEnd()
return $result

}
$url = "http://xxxxxx/index.php/admin/remotecontrol"
function survey-get-session{
param([string]$url)
$data = "<?xml version=""1.0""?>
<methodCall>
<methodName>get_session_key</methodName>
<params>
<username>
<value>admin</value>
</username>
<password>
<value>xxxxx</value>
</password>
</params>
</methodCall>"
[xml]$res_xml = [xml](PostWebRequest $url $data)
$session_key = $res_xml.methodResponse.params.param.value.string."#cdata-section"
if($session_key -ne $null){
return $session_key
}
else{
$Host.get_UI().WriteErrorLine("can't get session!")
return $null
}
}
function survey-release-session{
param(
[string]$url,
[string]$session
)
$data = "<?xml version=""1.0""?>
<methodCall>
<methodName>release_session_key</methodName>
<params>
<sSessionKey>
<value>"+$session+"</value>
</sSessionKey>
</params>
</methodCall>"
[xml]$res_xml = [xml](PostWebRequest $url $data)
$closed = $res_xml.methodResponse.params.param.value.string."#cdata-section"
if($closed -ne $null){
return $closed
}
else{
$Host.get_UI().WriteErrorLine("can't close session!")
return $null
}
}

function survey-list-surveys{
param(
[string]$url,
[string]$session,
[string]$user=$null
)
$data = "<?xml version=""1.0""?>
<methodCall>
<methodName>list_surveys</methodName>
<params>
<sSessionKey>
<value>"+$session+"</value>
</sSessionKey>
<sUser>
<value>"+$user+"</value>
</sUser>
</params>
</methodCall>"
$objs=@()
$props = @{sid = ""; surveyls_title = ""; startdate = ""; expires = ""; active = ""}
$obj = New-Object -TypeName PSObject -Property $props

[xml]$res_xml = [xml](PostWebRequest $url $data)
$list = $res_xml.methodResponse.params.param.value.array.data

foreach($val in $list.value){
    $struct = $val.struct
    $obj_cur = $obj.PSObject.Copy()
    foreach($mem in $struct.member){
        $param_name = $mem.name.FirstChild.value
        $param_value = $mem.value.FirstChild.FirstChild.value
        $obj_cur.($param_name) = $param_value
    }
    $objs+=$obj_cur
}
if($objs -ne $null){
    return $objs
}
else{
    $Host.get_UI().WriteErrorLine(&quot;can't get list of surveys!&quot;)
    return $null
}

}
function survey-add{
param(
[string]$url,
[string]$session,
[string]$title,
[string]$lang="ru",
[string]$fmt="G"
)
[long]$id = Random(999999)
$data = "<?xml version=""1.0""?>
<methodCall>
<methodName>add_survey</methodName>
<params>
<sSessionKey>
<value>"+$session+"</value>
</sSessionKey>
<iSurveyID>
<value/>"+$id+"</value>
</iSurveyID>
<sSurveyTitle>
<value>"+$title+"</value>
</sSurveyTitle>
<sSurveyLanguage>
<value>"+$lang+"</value>
</sSurveyLanguage>
<sformat>
<value>"+$fmt+"</value>
</sformat>
</params>
</methodCall>"
Write-Host (PostWebRequest $url $data)
}

$session_key = (survey-get-session $url) # work!
if($session_key -ne $null){
    Write-Host (&quot;session = &quot;+$session_key)
    (survey-list-surveys $url $session_key) | ft –AutoSize # work!
    Write-Host (survey-add $url $session_key &quot;Test survey from RPC&quot;) # not work!
    Write-Host (survey-release-session $url $session_key) # work!
}

with replace working parameters (url and admin password)

TagsNo tags attached.
Attached Files
survey-rpc-test.ps1 (8,424 bytes)
Bug heat4
Complete LimeSurvey version number (& build)2.05+ Build 141210
I will donate to the project if issue is resolvedNo
Browser
Database type & versionmysql 5.5.40-0+wheezy1
Server OS (if known)Linux survey 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u1 x86_64 GNU/Linux
Webserver software & version (if known)Apache/2.2.22 (Debian)
PHP VersionPHP 5.4.35-0+deb7u2 (cli) (built: Nov 19 2014 07:56:24)

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2014-12-30 16:56

administrator   ~31404

Why are you under the impression that this is a bug in LimeSurvey? Did you check your script for bugs thoroughly?

c_schmitz

c_schmitz

2015-01-02 12:01

administrator   ~31408

Feedback please?

c_schmitz

c_schmitz

2015-01-06 10:35

administrator   ~31426

Closed due to missing feedback.

quarrier

quarrier

2015-01-27 15:48

reporter   ~31491

I'm sorry for silence, for some reasons i couldn't send feedback earlier. I was not know how to check script for errors because i not seen examples using for XML-RPC.
The following methods I work normally:
get_session_key
release_session_key
list_surveys
list_users
If i can see example for method or you can specify error in next xml data
<?xml version="1.0"?>
<methodCall>
<methodName>add_survey</methodName>
<params>
<sSessionKey>
<value>9s7zn4hqgqcpnu2mfizky8vrh9tnzyib</value>
</sSessionKey>
<iSurveyID>
<value>760956</value>
</iSurveyID>
<sSurveyTitle>
<value>Test survey from RPC</value>
</sSurveyTitle>
<sSurveyLanguage>
<value>ru</value>
</sSurveyLanguage>
<sformat>
<value>G</value>
</sformat>
</params>
</methodCall>
i was very grateful

c_schmitz

c_schmitz

2015-05-08 15:05

administrator   ~32144

In your original code above is a typo

<iSurveyID>
<value/>"+$id+"</value>
^^^^^
</iSurveyID>

Make sure you create valid XML. Please do not reeopn this issue. Thank you.

Issue History

Date Modified Username Field Change
2014-12-12 17:05 quarrier New Issue
2014-12-12 17:05 quarrier File Added: survey-rpc-test.ps1
2014-12-30 16:56 c_schmitz Note Added: 31404
2014-12-30 16:56 c_schmitz Assigned To => c_schmitz
2014-12-30 16:56 c_schmitz Status new => feedback
2015-01-02 12:01 c_schmitz Note Added: 31408
2015-01-06 10:34 c_schmitz Status feedback => closed
2015-01-06 10:34 c_schmitz Resolution open => unable to reproduce
2015-01-06 10:35 c_schmitz Note Added: 31426
2015-01-27 15:48 quarrier Note Added: 31491
2015-01-27 15:48 quarrier Status closed => feedback
2015-01-27 15:48 quarrier Resolution unable to reproduce => reopened
2015-05-08 15:05 c_schmitz Note Added: 32144
2015-05-08 15:05 c_schmitz Status feedback => closed
2015-05-08 15:05 c_schmitz Resolution reopened => unable to reproduce