PHPを使用してカールし、ラリーに不具合を作成しようとしています。Rally APIを使用してPHPとカールを使用して新しい不具合を作成する
<?php
define('XML_POST_URL', 'https://rally1.rallydev.com/slm/webservice/1.29/defect/create');
/**
* Initialize handle and set options
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, XML_POST_URL);
curl_setopt($ch, CURLOPT_USERPWD, '[USERNAME]:[PASSWORD]');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, '<Defect> <Description>blah blah blah</Description> <Name>my defect</Name> <Priority>None</Priority> <ReleaseNote>false</ReleaseNote> <Severity>Major Problem</Severity> <State>Open</State> <Owner ref=\"https://rally1.rallydev.com/slm/webservice/1.29/user/[USERID]\"/> </Defect>');
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
$result = curl_exec($ch);
/**
* Check for errors
*/
if (curl_errno($ch)) {
$result = 'cURL ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
echo "ERROR! " . $result;
} else {
$returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
switch($returnCode){
case 200:
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
curl_close($ch);
$xml_parser = xml_parser_create();
xml_parse($xml_parser, $result);
$returnXML = new SimpleXMLElement($result);
echo "<br>" . $returnXML->asXML();
>
returnXMLをプリントアウトしようと、私は次のエラーを取得:?
:私はしますprint_rを行うとSimpleXMLElement Object ([@attributes] => Array ([rallyAPIMajor] => 1 [rallyAPIMinor] => 29) [Errors] => SimpleXMLElement Object ([OperationResultError] => Cannot parse input stream as XML document: Error on line 1: Open quote is expected for attribute "{1}" associated with an element type "ref".) [Warnings] => SimpleXMLElement Object ())
Cannot parse input stream as XML document: Error on line 1: Open quote is expected for attribute "{1}" associated with an element type "ref".
が、私はこれを参照
私はこの例に似ていることを期待しています:https://rally1.rallydev.com/slm/doc/webservice/rest_xml.jsp
エラーメッセージは、の一部であるrefに問題があるように聞こえます。誰かが私が間違っていることを知っていますか?助けてくれてありがとう。