XML Request for Core

Hello everyone.

I’m working on IoT projects for salesforce. And i must integrate salesforce.com login process to core. In Salesforce’s Developer Page, advise me to cURL command. But as i understand, Core hasn’t provides this command. I have realised that process on Raspberry Pi that posting XML. Here is my Python Code on it.

import requests, codecs
def login(userName, password):

  request = u"""<?xml version="1.0" encoding="utf-8" ?>
  <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      <n1:login xmlns:n1="urn:partner.soap.sforce.com">
        <n1:username>""" + userName + """</n1:username>
        <n1:password>""" + password + """</n1:password>
  encoded_request = request.encode('utf-8')
  url = "https://login.salesforce.com/services/Soap/u/33.0"
  headers = {"Content-Type": "text/xml; charset=UTF-8",
             "SOAPAction": "login"}
  response = requests.post(url=url,
                           headers = headers,
                           data = encoded_request,
  return codecs.encode(response.text,'utf-8')

Thanks for your advices.

Just wondering if Webhooks will be a better choice - http://docs.particle.io/photon/webhooks/

like you can trigger a url hosting the script you write/wrote for the login instead of doing a direct request?

There is a guy who interfaced with a Sonos that should be using XML: Hover + Spark = Sonos Remote

1 Like

When i create webhook, can i use it as a text file?

What do mean use it as a text file? Basically, it allows you to trigger a url and send some data from a Particle device and the url/website will process the data accordingly/do stuff :wink:

But i’m trying to create webhook, it says a problem at below

C:\Users\Emre>particle webhook create emre.xml
Please specify an event name

You might want to take a look at the docs: http://docs.particle.io/photon/webhooks/#introduction

It doesn’t take an xml. The xml should be hosted somewhere and when the device triggers a webhook, the :cloud: will query the url where the xml file is hosted and return the result to the device

1 Like

but i must send datas to Salesforce.com directly. Because of it, i’m trying to HTTP request. But, i’m also have problems with that. I’m using client.read() command but, i’m getting an error, more trutly i’m getting -1 value on the putty console. How can i use the TCPClient functions? Please help mi. For other words has arduino got this specification ?

Hi @emrebekar67,

It sounds like you want an action on a Core or Photon to trigger an XML request to Salesforce. Webhooks let you register an HTTP request of an arbitrary request type and payload based on a publish event from your device.

If you want to send the XML payload directly from the device, you’ll probably want the HTTP Client library (which I believe is available in the IDE). Do you wanna email me at david (at) particle.io, and I’ll try to help unblock you?