function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marketing 20112Marketing 20112 

Costum button sending a http post with parameters

I'm trying to send a http post to our API using a costum detail page button executing javascript. 
The problem I'm having is that it seems the parameters needed for the API isn't coming through. 

This is the javascript running:

{!RequireScript("/soap/ajax/11.1/connection.js")}

var phone = '{!Contact.MobilePhone }'

postParams = {}
postParams.url = 'https://api.example.com/'
postParams.method = 'POST'
postParams.requestData = 'phonenumber='+phone
postParams.requestHeaders = {}
postParams.requestHeaders['Content-Type'] = 'text/plain' //or another mime-type
postParams.requestHeaders['Content-Length'] = postParams.requestData.length //required for POST
postParams.onSuccess = processSuccess
postParams.onError = processError
sforce.connection.remoteFunction(postParams)

function processSuccess(message)
{ // do something with results¨
alert(message);
}
function processError(message)
{ // do something with the error
alert('error');
}

Found this example in another question and worked from there. The API recives the post but with no "phonenumber"-parameter. What am I doing wrong?
pconpcon
I believe you want to set your Content-Type to be "application/x-www-form-urlencoded" not text/plain
Marketing 20112Marketing 20112
Thanks, works like a charm!