RightNow CRM XML API - 任何熟悉它的人

本文关键字:熟悉 任何 CRM XML API RightNow | 更新日期: 2023-09-27 17:47:21

我需要在 vb.net 或c#中创建一个用户控件来搜索RightNow CRM数据库。我有关于他们的 XML API 的文档,但我不确定如何发布到他们的解析器,然后捕获返回数据并将其显示在页面上。

任何示例代码将不胜感激!

链接到 API:http://community.rightnow.com/customer/documentation/integration/82_crm_integration.pdf

RightNow CRM XML API - 任何熟悉它的人

我不知道

RightNow CRM,但根据文档,您可以使用HTTP post发送XML请求。在 .NET 中执行此操作的最简单方法是使用 WebClient 类。或者,您可能想看看 HttpWebRequest/HttpWebResponse 类。下面是一些使用 WebClient 的示例代码:

using System.Net;
using System.Text;
using System;
namespace RightNowSample
{
    class Program
    {
        static void Main(string[] args)
        {
            string serviceUrl = "http://<your_domain>/cgi-bin/<your_interface>.cfg/php/xml_api/parse.php";
            WebClient webClient = new WebClient();
            string requestXml = 
@"<connector>
<function name=""answers_get"">
<parameter name=""args"" type=""pair"">
<pair name=""id"" type=""integer"">33</pair>
<pair name=""sub_tbl"" type='pair'>
<pair name=""tbl_id"" type=""integer"">164</pair>
</pair>
</parameter>
</function>
</connector>";
            string secString = "";
            string postData = string.Format("xml_doc={0}, sec_string={1}", requestXml, secString);
            byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);
            byte[] responseDataBytes = webClient.UploadData(serviceUrl, "POST", postDataBytes);
            string responseData = Encoding.UTF8.GetString(responseDataBytes);
            Console.WriteLine(responseData);
        }
    }
}

我无法访问RightNow CRM,所以我无法对此进行测试,但它可以作为您的关键点。

这将

在"立即"中创建联系人

   class Program
{
    private RightNowSyncPortClient _Service;
    public Program()
    {
        _Service = new RightNowSyncPortClient();
        _Service.ClientCredentials.UserName.UserName = "Rightnow UID";
        _Service.ClientCredentials.UserName.Password = "Right now password";
    }
    private Contact Contactinfo()
    {
        Contact newContact = new Contact();
        PersonName personName = new PersonName();
        personName.First = "conatctname";
        personName.Last = "conatctlastname";
        newContact.Name = personName;
        Email[] emailArray = new Email[1];
        emailArray[0] = new Email();
        emailArray[0].action = ActionEnum.add;
        emailArray[0].actionSpecified = true;
        emailArray[0].Address = "mail@mail.com";
        NamedID addressType = new NamedID();
        ID addressTypeID = new ID();
        addressTypeID.id = 1;
        addressType.ID = addressTypeID;
        addressType.ID.idSpecified = true;
        emailArray[0].AddressType = addressType;
        emailArray[0].Invalid = false;
        emailArray[0].InvalidSpecified = true;
        newContact.Emails = emailArray;
        return newContact;
    }
    public long CreateContact()
    {
        Contact newContact = Contactinfo();
        //Set the application ID in the client info header
        ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
        clientInfoHeader.AppID = ".NET Getting Started";
        //Set the create processing options, allow external events and rules to execute
        CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions();
        createProcessingOptions.SuppressExternalEvents = false;
        createProcessingOptions.SuppressRules = false;
        RNObject[] createObjects = new RNObject[] { newContact };
        //Invoke the create operation on the RightNow server
        RNObject[] createResults = _Service.Create(clientInfoHeader, createObjects, createProcessingOptions);
        //We only created a single contact, this will be at index 0 of the results
        newContact = createResults[0] as Contact;
        return newContact.ID.id;
    }
    static void Main(string[] args)
    {
        Program RBSP = new Program();
        try
        {
            long newContactID = RBSP.CreateContact();
            System.Console.WriteLine("New Contact Created with ID: " + newContactID);
        }
        catch (FaultException ex)
        {
            Console.WriteLine(ex.Code);
            Console.WriteLine(ex.Message);
        }
        System.Console.Read();
    }
}