Jump to content

API Help


ddwilli

Recommended Posts

I'm trying to use an API to submit a form and I'm not sure what I'm supposed to do with the ProcessName. This is the error I'm getting:

90028910falseInvalid Process Name0
<?xml version="1.0" encoding="UTF-8"?>
	<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.securecrmsite.com/">
		<SOAP-ENV:Body>
			<ns1:Process>
				<ns1:Credentials>
					<ns1:CompanyKey>xxxx</ns1:CompanyKey>
					<ns1:APIKey>xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</ns1:APIKey>
				</ns1:Credentials>
			</ns1:Process>
		<param1>
			<item>
				<key>ProcessName</key>
				<value>CompanyInsert</value>
			</item>
			<item>
				<key>FirstName</key>
				<value>From</value>
			</item>
			<item>
				<key>LastName</key>
				<value>API</value>
			</item>
		</param1>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And this is the code I have:

$compKey = 'xxxx';
$apiKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$soapURL = "https://www.securecrmsite.com/Modules/System/API.asmx?wsdl";
$soapCredentials = array('Credentials'=>array('CompanyKey' => $compKey, 'APIKey' => $apiKey));
$soapFunctionParameters = array('ProcessName' => "CompanyInsert", 'FirstName' => "From", 'LastName' => "API");
$client = new SoapClient($soapURL, array('trace' => true));
$client->Process($soapCredentials, $soapFunctionParameters);
echo $client->__getLastResponse();

If anyone has any ideas, they'd be greatly appreciated! I don't have much experience working with APIs. Thanks.

Link to comment
Share on other sites

API's are arbitrarily coded scripts. There's no universally defined syntax for how to send data to an API or receive data from it. So, the only way we can do more than make random guesses is by being able to see the API's documentation.

 

Having said that.. based on what you've shown... the error says "invalid process name". I would start with making sure you are sending a valid process name in your request. It seems from your code you are setting it in $soapFunctionParameters. It seems you are using a value of "CompanyInsert". Are you sure that's the right value? Are you sure that's how you're actually supposed to supply the value, in an array structured like that, etc..?

Link to comment
Share on other sites

I accidentally posted an older version I had and that one did have the wrong ProcessName, but it's still the same error with the right ProcessName. My problem is I don't know where to put it. This is the documentation, they only have a VB version. It looks like the line should be $client->Process($soapCredentials, "CustomerInsert", $soapFunctionParameters), but that still gives the same error.

Credentials	 Credentials() (Collection of valid and active API Key and Company Key)	 Your valid and active system credentials
ProcessName	 String	 CustomerInsert
WebServiceParams	 WebServiceParams()(Collection of name/value pairs)	 
JointCustomerID - INT (OPTIONAL)
CompanyAffiliateID - INT (OPTIONAL)
CompanyAffiliateIDAlt1 - INT (OPTIONAL)
CompanyAffiliateIDAlt2 - INT (OPTIONAL)
CaseAgentUserID - INT (OPTIONAL)
SalesRepUserID - INT (OPTIONAL)
DisputeRecordTypeID - INT (OPTIONAL)
CustomerStatusID - INT (OPTIONAL)
CustomerFolderID - INT (OPTIONAL)
CustomerWorkflowID - INT (OPTIONAL)
Prefix - NVARCHAR (OPTIONAL)
FirstName - NVARCHAR (REQUIRED)
LastName - NVARCHAR (REQUIRED)
Suffix - NVARCHAR (OPTIONAL)
Address - NVARCHAR (OPTIONAL)
City - NVARCHAR (OPTIONAL)
State - NVARCHAR (OPTIONAL)
PostalCode - NVARCHAR (OPTIONAL)
Phone - NVARCHAR (OPTIONAL)
AltPhone - NVARCHAR (OPTIONAL)
Fax - NVARCHAR (OPTIONAL)
SSN - NVARCHAR (OPTIONAL)
DOB - NVARCHAR (OPTIONAL)
Email - NVARCHAR (OPTIONAL)
Notes - NVARCHAR (OPTIONAL)
InternalNotes - NVARCHAR (OPTIONAL)
Source - NVARCHAR (OPTIONAL)
AllowEmails - BOOLEAN True/False (OPTIONAL)

Public Class MainClass

    Public Shared Sub Main()
         InvokeProcess()
    End Sub

    Public Shared Sub InvokeProcess()
         Dim api As api = New api
         Dim credentials As ApiCredentials = New ApiCredentials
         credentials.CompanyKey = "test"
         credentials.APIKey = "test"
         Dim parameters(28) As ApiParams

         Dim parameters_0 As ApiParams = New ApiParams
         parameters_0.Name = "JointCustomerID"
         parameters_0.Value = "[VALID VALUE]"
         parameters(0) = parameters_0
         Dim parameters_1 As ApiParams = New ApiParams
         parameters_1.Name = "CompanyAffiliateID"
         parameters_1.Value = "[VALID VALUE]"
         parameters(1) = parameters_1
         Dim parameters_2 As ApiParams = New ApiParams
         parameters_2.Name = "CompanyAffiliateIDAlt1"
         parameters_2.Value = "[VALID VALUE]"
         parameters(2) = parameters_2
         Dim parameters_3 As ApiParams = New ApiParams
         parameters_3.Name = "CompanyAffiliateIDAlt2"
         parameters_3.Value = "[VALID VALUE]"
         parameters(3) = parameters_3
         Dim parameters_4 As ApiParams = New ApiParams
         parameters_4.Name = "CaseAgentUserID"
         parameters_4.Value = "[VALID VALUE]"
         parameters(4) = parameters_4
         Dim parameters_5 As ApiParams = New ApiParams
         parameters_5.Name = "SalesRepUserID"
         parameters_5.Value = "[VALID VALUE]"
         parameters(5) = parameters_5
         Dim parameters_6 As ApiParams = New ApiParams
         parameters_6.Name = "DisputeRecordTypeID"
         parameters_6.Value = "[VALID VALUE]"
         parameters(6) = parameters_6
         Dim parameters_7 As ApiParams = New ApiParams
         parameters_7.Name = "CustomerStatusID"
         parameters_7.Value = "[VALID VALUE]"
         parameters(7) = parameters_7
         Dim parameters_8 As ApiParams = New ApiParams
         parameters_8.Name = "CustomerFolderID"
         parameters_8.Value = "[VALID VALUE]"
         parameters( = parameters_8
         Dim parameters_9 As ApiParams = New ApiParams
         parameters_9.Name = "CustomerWorkflowID"
         parameters_9.Value = "[VALID VALUE]"
         parameters(9) = parameters_9
         Dim parameters_10 As ApiParams = New ApiParams
         parameters_10.Name = "Prefix"
         parameters_10.Value = "[VALID VALUE]"
         parameters(10) = parameters_10
         Dim parameters_11 As ApiParams = New ApiParams
         parameters_11.Name = "FirstName"
         parameters_11.Value = "[VALID VALUE]"
         parameters(11) = parameters_11
         Dim parameters_12 As ApiParams = New ApiParams
         parameters_12.Name = "LastName"
         parameters_12.Value = "[VALID VALUE]"
         parameters(12) = parameters_12
         Dim parameters_13 As ApiParams = New ApiParams
         parameters_13.Name = "Suffix"
         parameters_13.Value = "[VALID VALUE]"
         parameters(13) = parameters_13
         Dim parameters_14 As ApiParams = New ApiParams
         parameters_14.Name = "Address"
         parameters_14.Value = "[VALID VALUE]"
         parameters(14) = parameters_14
         Dim parameters_15 As ApiParams = New ApiParams
         parameters_15.Name = "City"
         parameters_15.Value = "[VALID VALUE]"
         parameters(15) = parameters_15
         Dim parameters_16 As ApiParams = New ApiParams
         parameters_16.Name = "State"
         parameters_16.Value = "[VALID VALUE]"
         parameters(16) = parameters_16
         Dim parameters_17 As ApiParams = New ApiParams
         parameters_17.Name = "PostalCode"
         parameters_17.Value = "[VALID VALUE]"
         parameters(17) = parameters_17
         Dim parameters_18 As ApiParams = New ApiParams
         parameters_18.Name = "Phone"
         parameters_18.Value = "[VALID VALUE]"
         parameters(18) = parameters_18
         Dim parameters_19 As ApiParams = New ApiParams
         parameters_19.Name = "AltPhone"
         parameters_19.Value = "[VALID VALUE]"
         parameters(19) = parameters_19
         Dim parameters_20 As ApiParams = New ApiParams
         parameters_20.Name = "Fax"
         parameters_20.Value = "[VALID VALUE]"
         parameters(20) = parameters_20
         Dim parameters_21 As ApiParams = New ApiParams
         parameters_21.Name = "SSN"
         parameters_21.Value = "[VALID VALUE]"
         parameters(21) = parameters_21
         Dim parameters_22 As ApiParams = New ApiParams
         parameters_22.Name = "DOB"
         parameters_22.Value = "[VALID VALUE]"
         parameters(22) = parameters_22
         Dim parameters_23 As ApiParams = New ApiParams
         parameters_23.Name = "Email"
         parameters_23.Value = "[VALID VALUE]"
         parameters(23) = parameters_23
         Dim parameters_24 As ApiParams = New ApiParams
         parameters_24.Name = "Notes"
         parameters_24.Value = "[VALID VALUE]"
         parameters(24) = parameters_24
         Dim parameters_25 As ApiParams = New ApiParams
         parameters_25.Name = "InternalNotes"
         parameters_25.Value = "[VALID VALUE]"
         parameters(25) = parameters_25
         Dim parameters_26 As ApiParams = New ApiParams
         parameters_26.Name = "Source"
         parameters_26.Value = "[VALID VALUE]"
         parameters(26) = parameters_26
         Dim parameters_27 As ApiParams = New ApiParams
         parameters_27.Name = "AllowEmails"
         parameters_27.Value = "[VALID VALUE]"
         parameters(27) = parameters_27
         Dim processResult As ApiResponse = api.Process(credentials, "CustomerInsert", parameters)
         Dumper.Dump("result", processResult)
    End Sub

End Class
Link to comment
Share on other sites

Does the code I have at least look right or am I way off? This is the proper code I meant to post before.

$compKey = 'xxxx';
$apiKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$soapURL = "https://www.securecrmsite.com/Modules/System/API.asmx?wsdl";
$soapCredentials = array('Credentials'=>array('CompanyKey' => $compKey, 'APIKey' => $apiKey));
$soapFunctionParameters = array('FirstName' => "From", 'LastName' => "API");
$client = new SoapClient($soapURL, array('trace' => true));
$client->Process($soapCredentials, "CustomerInsert", $soapFunctionParameters);
echo $client->__getLastResponse();
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.