PHP | SOAP 1.2 | How to set WS Addressing - php

Here is the WSDL ...
I am using the SOAP Client in PHP with documentation HERE ...
Soap Call
$wsdl = 'https://api.krollcorp.com/EBusinessTest/Kroll.Dealer.EBusiness.svc/Docs?singleWsdl';
try {
$client = new SoapClient($wsdl, array('soap_version' => SOAP_1_2, 'trace' => 1));
// $result = $client->SubmitPurchaseOrder();
$result = $client->__soapCall("SubmitPurchaseOrder", array());
} catch (SoapFault $e) {
printf("\nERROR: %s\n", $e->getMessage());
}
$requestHeaders = $client->__getLastRequestHeaders();
$request = $client->__getLastRequest();
$responseHeaders = $client->__getLastResponseHeaders();
printf("\nRequest Headers -----\n");
print_r($requestHeaders);
printf("\nRequest -----\n");
print_r($request);
printf("\nResponse Headers -----\n");
print_r($responseHeaders);
printf("\nEND\n");
Output
ERROR: The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://tempuri.org/IEBusinessService/SubmitPurchaseOrder'.
Request Headers -----
POST /EBusinessTest/Kroll.Dealer.EBusiness.svc HTTP/1.1
Host: api.krollcorp.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.19
Content-Type: application/soap+xml; charset=utf-8; action="http://tempuri.org/IEBusinessService/SubmitPurchaseOrder"
Content-Length: 200
Request -----
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://tempuri.org/"><env:Body><ns1:SubmitPurchaseOrder/></env:Body></env:Envelope>
Response Headers -----
HTTP/1.1 500 Internal Server Error
Content-Length: 637
Content-Type: application/soap+xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Wed, 06 Sep 2017 12:42:57 GMT
END
Attempts
I am a beginner at using SOAP APIs.
I believe this is failing because SOAP 1.2 uses WsHttpBinding instead of BasicHttpBinding.
I am not sure how to set WS Addressing with the SOAP Client in PHP ...

Below code is working for me.You can enable Ws-A Addressing and call soap method-
$client = new SoapClient("http://www.xyz.Services?Wsdl", array('soap_version' => SOAP_1_2,'trace' => 1,'exceptions'=> false
));
$wsa_namespace = 'http://www.w3.org/2005/08/addressing';
$ACTION_ISSUE = 'http://www.xyx/getPassword';// Url With method name
$NS_ADDR = 'http://www.w3.org/2005/08/addressing';
$action = new SoapHeader($NS_ADDR, 'Action', $ACTION_ISSUE, true);
$to = new SoapHeader($NS_ADDR, 'To', 'http://www.xyx.svc/Basic', false);
$headerbody = array('Action' => $action,'To' => $to);
$client->__setSoapHeaders($headerbody);
//$fcs = $client->__getFunctions();
//pre($client->__getLastRequest());
//pre($fcs);
$parameters=array('UserId'=>'12345678','MemberId'=>'123456','Password' => '123456','PassKey' => 'abcdef1234');
;
$result = $client->__soapCall('getPassword', array($parameters));//getPassword method name
print_r(htmlspecialchars($client->__getLastRequest()));// view your request in xml code
print_r($client->__getLastRequest());die; //Get Last Request
print_r($result);die; //print response

Dude, I totally feel your pain. I was able to get this to work but I don't think this is the right way, but it is pointing in the right direction. A caveat though, you have to know what namespace soap_client is going to assign to the addressing. Best way is just to capture the request XML and look for what namespace is attache to the addressing, and then pass it in. Below is my code with a default of 'ns2' for namespace, but you can't count on it for your example. Good Luck!
private function generateWSAddressingHeader($action,$to,$replyto,$message_id=false,$ns='ns2')
{
$message_id = ($message_id) ? $message_id : $this->_uniqueId(true);
$soap_header = <<<SOAP
<{$ns}:Action env:mustUnderstand="0">{$action}</{$ns}:Action>
<{$ns}:MessageID>urn:uuid:{$message_id}</{$ns}:MessageID>
<{$ns}:ReplyTo>
<{$ns}:Address>{$replyto}</{$ns}:Address>
</{$ns}:ReplyTo>
<{$ns}:To env:mustUnderstand="0">$to</{$ns}:To>
SOAP;
return new \SoapHeader('http://www.w3.org/2005/08/addressing','Addressing',new \SoapVar($soap_header, XSD_ANYXML),true);
}

My solution is
Send request using SoapUi
Copy request http log from SoapUi screen ( Bottom of SoapUi program)
Past that code into the PHP project as fallows
$soap_request = '{copy that part from SoapUi http log}';
$WSDL = "**wsdl adres**";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $WSDL);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array(
'Content-Type: application/soap+xml; charset=utf-8',
'SOAPAction: "run"',
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
'Content-length: '. strlen($soap_request),
'User-Agent: PHP-SOAP/7.0.10',
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $soap_request);
$response = curl_exec($ch);
if (empty($response)) {
throw new SoapFault('CURL error: '.curl_error($ch), curl_errno($ch));
}
curl_close($ch);

Related

Forbidden to Call method on Dynamics 365 AX via PHP Curl

I am trying to call methods from dynamics SOAP through WSDL via PHP curl.
I get this error from both my webapp and SOAPUI.
What could be the problem? It works fine when accessed from a .NET testing program with same credentials. Just facing problems from PHP side saying Forbidden with 1317 code. The specified account does not exist
I've been trying to call the method and faced different issues last issue I faced is this one.
I thought maybe user agent I changed it I used SOAPUI. same thing.
What I know is the user is registered in Azure AD and should have authorization for the app.
The POST is
POST /soap/services/servicemethodname?wsdl
HTTP/1.1
Host: domainname.sandbox.ax.dynamics.com
Accept: text/xml
Accept-Encoding: gzip,deflate
Connection: Keep-Alive
Content-type: text/xml
User-Agent: Apache-HttpClient
Authorization: Bearer longTokenString
Soapaction: "http://tempuri.org/webservice/method"
Content-Length: 795
The Response is
HTTP/1.1 500 Internal Server Error Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/10.0
Strict-Transport-Security: max-age=31536000; includeSubDomains
Set-Cookie: ASP.NET_SessionId=hghtgkuhlihkjg; path=/; secure;
HttpOnly Set-Cookie:
ms-dyn-csrftoken= someTokenSTring; path=/; secure
ms-dyn-fqhn:
ms-dyn-namespace: namespace
ms-dyn-tenant: tenantidstring
ms-dyn-role:
ms-dyn-aid: aidString
X-Powered-By: ASP.NET
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
p3p: CP="No P3P policy defined. Read the Microsoft privacy statement at https://go.microsoft.com/fwlink/?LinkId=271135"
Strict-Transport-Security: max-age=31536000;
includeSubDomains Date: Thu, 01 Aug 2019 19:24:52 GMT Content-Length: 1112
a:ForbiddenForbidden1317System.ComponentModel.Win32ExceptionThe specified account does not exist0-2147467259
I need to be able to call the method without errors and get the values it sends.
My php code
$requestBody = trim('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dat="http://schemas.microsoft.com/dynamics/2013/01/datacontracts" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tem="http://tempuri.org">
<soapenv:Header>
<dat:CallContext>
<dat:Company>company</dat:Company>
<dat:Language>en-us</dat:Language>
<dat:MessageId>?</dat:MessageId>
<dat:PartitionKey>12345667</dat:PartitionKey>
</dat:CallContext>
</soapenv:Header>
<soapenv:Body>
<m:getMethod xmlns:m="http://tempuri.org/webService/getMethod">
<m:parameterName soap:mustUnderstand="1">12345</m:parameterName>
</m:getMethod>
</soapenv:Body>
</soapenv:Envelope>
');
$soapAction = 'SOAPAction: http://tempuri.org/webService/getMethod';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,
array( 'Accept:text/xml',
'Accept-Encoding: gzip,deflate',
'Connection: Keep-Alive',
'Content-type: text/xml; charset=utf-8',
'Cache-Control: no-cache',
'Pragma: no-cache',
'Authorization: Bearer longstringToken',
'SOAPAction: http://tempuri.org/webService/getMethod'
));
if ($postData != '') {
curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
// By default https does not work for CURL.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt ($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
// Set the option to recieve the response back as string.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$odataURL = 'https://domainname.sandbox.ax.dynamics.com/soap/services/webService';
curl_setopt($ch, CURLOPT_URL, $odataURL);
// enable string response
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, true);
// Mark as Post request
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
// $output contains the output string
$output = curl_exec($ch);
Ok so finally found a solution.
It helps to read documentations on the classes you use and different systems used. In my case i was trying to integrate my app with microsoft dynamics 365 ax, so i had to read up on that too.
I read a lot of documents some were related to different dynamics service but this one helped most
And since the soap service needed Authorization Header, because they were using Windows authentication, we needed to get the token from oAuth link.
https://login.windows.net/$tenantDomainName/oauth2/token
PS: the oauth2 link i knew about it from github PHPConsoleApplication
I used PHP CURL to get my authorization Token and then created a client using PHP's SoapClient Class.
Make sure you add the authorization token in the header like so:
$arrayOpt = array(
'stream_context' => stream_context_create(
array('http' =>'Authorization: Bearer tokenString')
));
$client = new SoapClient($wsdl, $arrayOpt);
$response = $client->serviceMethod($parameters);
var_dump($response);
And you will get the values of the method.

Subscribe using Superfeedr PubSubHubbub generating error hub.topic not found

I want to integrate Superfeedr API using PubSubHubbub in PHP. I am following this and my code is:
<?php
require_once('Superfeedr.class.php')
$superfeedr = new Superfeedr('http://push-pub.appspot.com/feed',
'http://mycallback.tld/push?feed=http%3A%2F%2Fpush-pub.appspot.com%2Ffeed',
'http://wallabee.superfeedr.com');
$superfeedr->verbose = true;
$superfeedr->subscribe();
?>
And my subscribe() function is
public function subscribe()
{
$this->request('subscribe');
}
private function request($mode)
{
$data = array();
$data['topic'] = $this->topic;
$data['callback'] = $this->callback;
$post_data = array (
"hub.mode" => 'subscribe',
"hub.verify" => "sync",
"hub.callback" => urlencode($this->callback),
"hub.topic" => urlencode($this->topic),
"hub.verify_token" => "26550615cbbed86df28847cec06d3769",
);
//echo "<pre>"; print_r($post_data); exit;
// url-ify the data for the POST
foreach ($post_data as $key=>$value) {
$post_data_string .= $key.'='. $value.'&';
}
rtrim($fields_string,'&');
// curl request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->hub);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_USERPWD, 'USERNAME:PASSWORD');
$output = curl_exec($ch);
if ($this->verbose) {
print('<pre>');
print_r($output);
print('</pre>');
}
}
But after execution I am getting this error
HTTP/1.1 422 Unprocessable Entity
X-Powered-By: The force, Luke
Vary: X-HTTP-Method-Override, Accept-Encoding
Content-Type: text/plain; charset=utf-8
X-Superfeedr-Host: supernoder16.superfeedr.com
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Headers: Authorization
Content-Length: 97
ETag: W/"61-db6269b5"
Date: Wed, 24 Aug 2016 14:01:47 GMT
Connection: close
Please provide a valid hub.topic (feed) URL that is accepted on this hub. The hub does not match.
Same data (topic and callback etc..) requesting from https://superfeedr.com/users/testdata/push_console
is working fine. But I don't know why I am getting this error on my local. If anyone has any experienced with same problom then please help me. Thanks.
You are using a strange hub URL. You should use HTTPS://push.superfeedr.com in the last param of your class constructor.

cURL unable to use client certificate (no key found or wrong pass phrase?)

I have read and tried thousands of solutions in different posts and none of them seems to work with me. This three are example of that.
cURL is unable to use client certificate , in local server
php openssl_get_publickey() and curl - unable to use client certificate (no key found or wrong pass phrase?)
Getting (58) unable to use client certificate (no key found or wrong pass phrase?) from curl
I received a .p12 certificate which I converted to .pem file in https://www.sslshopper.com/ssl-converter.html
The password is correct otherwise it wouldn't convert it.
$xml = 'my xml here';
$url = 'https://qly.mbway.pt/Merchant/requestFinancialOperationWS';
$headers = array(
'Content-Type: text/xml; charset="utf-8"',
'Content-Length: ' . strlen($xml),
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSLCERT, base_url() . 'public/cert.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'my password here');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
$data = curl_exec($ch);
if(!$data)
print_r('ERROR: ' . curl_error($ch));
else
print_r('SUCCESS: ' . curl_error($ch));
I have tried with SoapUI application and works fine but with cURL I'm receiving the error:
unable to use client certificate (no key found or wrong pass phrase?)
I have tried without success:
Disable CURLOPT_SSL_VERIFYPEER and/or CURLOPT_SSL_VERIFYHOST
Add CURLOPT_SSLKEYTYPE and/or CURLOPT_SSLKEY fields
EDIT 1:
I have been trying around with SOAPClient besides cURL and it seems that the error might be the headers.
My headers after print_r($soapClient) are the following:
Host: qly.mbway.pt
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.5.9-1ubuntu4.14
Content-Type: application/soap+xml; charset=utf-8; action=""
Content-Length: 1750
I would like to know how can I remove the action=""? I tried to extend the original class without success in terms of changing the header.
class MySoapClient extends SoapClient
{
public function __construct($wsdl, $options = array())
{
$ctx_opts = array('http' => array('header' => array('Content-Type' => 'application/soapyyyyyml')));
$ctx = stream_context_create($ctx_opts);
parent::__construct($wsdl, array('stream_context' => $ctx));
}
}
Solved with cURL.
The problem was the path of the pem file.
I was using base_url() . 'public/cert.pem' but that's not possible. Instead I need to use a relative path such as ./public/cert.pem.

Unable to call .NET ASMX from PHP

I have the following - currently hosted - SOAP service that was created in .NET that I'm trying to call from PHP:
POST /ExampleService/ExampleService.asmx HTTP/1.1
Host: dev.examplesite.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://localhost:51713/ExampleService.asmx/RegisterPerson"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<UserCredentials xmlns="http://localhost:51713/ExampleService.asmx">
<UserID>string</UserID>
<AuthKey>string</AuthKey>
</UserCredentials>
</soap:Header>
<soap:Body>
<RegisterPerson xmlns="http://localhost:51713/ExampleService.asmx">
<requestItem>
<RequestResult>string</RequestResult>
<Firstname>string</Firstname>
<Lastname>string</Lastname>
</requestItem>
</RegisterPerson>
</soap:Body>
</soap:Envelope>
and I'm trying to call it using the following PHP code:
<?php
$ns = "http://dev.examplesite.com/ExampleService/ExampleService.asmx";
$wsdl_url = "http://dev.examplesite.com/ExampleService/ExampleService.asmx?wsdl";
$client = new SOAPClient($wsdl_url);
$header = new SoapHeader(
$ns,
'UserCredentials',
array(
'UserID' => "1",
'AuthKey' => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
)
);
$client->__setSoapHeaders($header);
$params = array(
'Firstname' => 'John',
'Lastname' => 'Doe'
);
$client->__soapCall('RegisterPerson',$params);
?>
This however results in the following error:
Fatal error: Uncaught SoapFault exception: [soap:MustUnderstand] Missing required header 'UserCredentials'. in /home/devops1/public_html/asmxtest/register.php:43 Stack trace: #0 /home/devops1/public_html/asmxtest/register.php(43): SoapClient->__soapCall('RegisterPerso...', Array) #1 {main} thrown in /home/devops1/public_html/asmxtest/register.php on line 43
I've tried a few other methods but all met with no success. One thing that concerns me is the fact that we are reaching across over the wire to this web service which is already hosted on a testing server, and the localhost:51713 is ringing alarm bells. Should this be changed to a fully qualified domain name such as dev.examplesite.com?
For as easy as the SoapClient is supposed to be, I've never had success w/ it. In just about every case we have rolled our own process, which always seemed to work better.
Example:
// set our headers to pass in cURL
$headers = array(
'Content-type: text/xml;charset="utf-8"',
'Accept: text/xml',
'Cache-Control: no-cache',
'Pragma: no-cache',
'SOAPAction: ' . $action,
'Content-length: '.strlen($soap)
);
// initiate cURL
try {
$_ch = curl_init();
curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($_ch, CURLOPT_URL, WEB_SERVICE_URL);
curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_ch, USERPWD, USER_ID . ":" . PASSWORD);
curl_setopt($_ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($_ch, CURLOPT_TIMEOUT, 10);
curl_setopt($_ch, CURLOPT_POST, true);
curl_setopt($_ch, CURLOPT_POSTFIELDS, $soap);
curl_setopt($_ch, CURLOPT_HTTPHEADER, $headers);
// process the request and get the result back
$response = curl_exec($_ch);
curl_close($_ch);
return $response;
} catch (Exception $e) {
capDebug(__FILE__, __LINE__, "Error calling the web service: " . $e->getMessage(), "/tmp/errors.log");
return false;
}
We've had to massage the data afterwards, but it always works!

How to perform a PUT operation using CURL in PHP?

I would like to perform a PUT operation on a webservice using CURL. Let's assume that:
webservice url: http://stageapi.myprepaid.co.za/api/ConsumerRegisterRequest/cac52674-1711-e311-b4a8-00155d4905d3
municipality= NMBM
sgc= 12345
I've written the code below, but it outputs this error message: "ExceptionMessage":"Object reference not set to an instance of an object.". Any help would be so much appreciated. Thanks!
<?php
function sendJSONRequest($url, $data)
{
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'X-MP-Version: 10072013')
);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
ob_start();
$result = curl_exec($ch);
$info = curl_getinfo($ch);
if ($result === false || $info['http_code'] == 400) {
return $result;
} else {
return $result;
}
ob_end_clean();
curl_close($ch);
}
$mun = $_GET['municipality'];
$sgc = $_GET['sgc'];
$req = $_GET['req']; //cac52674-1711-e311-b4a8-00155d4905d3
//myPrepaid PUT URL
echo $mpurl = "http://stageapi.myprepaid.co.za/api/ConsumerRegisterRequest/$req";
// Set Variables
$data = array("Municipality" => "$mun", "SGC" => "$sgc");
//Get Response
echo $response = sendJSONRequest($mpurl, $data);
?>
I copied your code, but changed it so it pointed at a very basic HTTP server on my localhost. Your code is working correctly, and making the following request:
PUT /api/ConsumerRegisterRequest/cac52674-1711-e311-b4a8-00155d4905d3 HTTP/1.1
Host: localhost:9420
Content-Type: application/json
Accept: application/json
X-MP-Version: 10072013
Content-Length: 37
{"Municipality":"NMBM","SGC":"12345"}
The error message you're receiving is coming from the stageapi.myprepaid.co.za server. This is the full response when I point it back to them:
HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 30 Aug 2013 04:30:41 GMT
Connection: close
Content-Length: 867
{"Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":" at MyPrepaidApi.Controllers.ConsumerRegisterRequestController.Put(CrmRegisterRequest value) in c:\\Workspace\\MyPrepaid\\Prepaid Vending System\\PrepaidCloud\\WebApi\\Controllers\\ConsumerRegisterRequestController.cs:line 190\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}
You may want to check out the API to make sure you're passing them the correct information. If you are, the problem could be on their end.
And while I realize this isn't part of your question and this is in development, please remember to sanitize any data from $_GET. :)
Try with:
curl_setopt($ch, CURLOPT_PUT, true);

Categories