• Wade Wegner
  • NEWBIE
  • 5 Points
  • Member since 2014
  • Principal Platform Architect
  • salesforce.com


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 21
    Replies
If is use REST API Callouts to push and pull the data from SFDC, how my external application will automatically authenticate the sfdc user?
I use .net api to login with portal user, the user name and password are correct, but threw exception as below,

Anyone can help me? Thanks very much.

Client found response content type of 'text/html;charset=UTF-8', but expected 'text/xml'.
The request failed with the error message:
--


<!-- ...................................................................................................
       ...................................................................................................
       ...................................................................................................
       ................................................................................................... -->

<div style="display:none;" id="errorTitle">Unable to Access Page</div>
<div style="display:none;" id="errorDesc">The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.</div>
<table cellspacing="10">
<tr><td><span style="font-weight: bold; font-size: 12pt;">Unable to Access Page</span></td></tr>
<tr><td>
The value of the "id" parameter contains a character that is not allowed or the value exceeds the maximum allowed length. Remove the character from the parameter value or reduce the value length and resubmit. If the error still persists, report it to our Customer Support team. Provide the URL of the page you were requesting as well as any other related information.
<br><br>

<a href="javascript:history.back()" class="back">Back</a>
</td></tr>
</table>
</td></tr>
</table>




<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>
  
</body>
</html>


<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->

--.
  • February 22, 2014
  • Like
  • 0
we want to integrate Salesforce with Java application using Rest API for authentication we want to use User-Agent OAuth Authentication dont want to expose the Username and password 


                string URI = 'https://cs1.salesforce.com/services/oauth2/authorize?response_type=code&' + 'client_id=' + ConsumerKey + '&' + 'client_secret=' + clientId + '&' + 'redirect_uri=' + redirectUri;
       
  HttpRequest req = new HttpRequest();
                req.setEndpoint(URI);
                req.setMethod('GET');
                Http http = new Http();
                HTTPResponse res = http.send(req);
                System.debug('response is'+res+'body is'+res.getBody ()+'*** After Authentication...');

I am getting Status Code 302  and redirecting to URL.

My question how can we use Oauth autentication without username and password Java to Salesforce inegration? 

  • February 17, 2014
  • Like
  • 0
I would like to create a custom object and then upload PDF attachments to it.  Any one done this?  Is it possible to do that?  I know there isn't a data type for PDF attachments, but I thought I saw an Attachment section on the page created for the custom object.
Hi,

I am able to do the callouts from salesforce to Heroku. But now I want to do the secured callouts from salesfoce to Heroku using the Certificates. Can anyone help me to do the secured callouts from salesforce to Heroku

Hello,

I am trying to retrieve installed package related information (like package name, version) using C#.net application code.

As per documentation, ideally we should be able to get package related information using “MetaData API”. I have added MetaData API 's WebReference in my C# application

I am able to validate supplied credentials but not able to retrieve package information using below methods:
•listMetadata
• Retrieve

Don't know what I'm doing wrong here...
Please let me know if you know how to retrieve the information.

I have created a connected app through our company's developer account and was wondering if it is okay to use this app in production or do we need another type of Salesforce account?
I have no problems connecting to salesforce api from a console app.

however, when I execute the same call from a web project, it hangs and times out on this line:

    Svc.login(_username, _password + _token);

where Svc is

    SFDC2.SforceService : System.Web.Services.Protocols.SoapHttpClientProtocol

again, this same code is used no problem from a console app within the same solution

i am connecting using a web reference, based on a the generated WSDL from salesfroce.com admin screen.

there is a hidden exception

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
i m not able to find customize|live agent | developers is this availiable for trial version
Hello,

I am using Bulk Api with C#.net.
every time I am getting below error if xml file has more than 50 records.

<stateMessage>InvalidBatch : Failed to parse XML. Found invalid XML. entity reference names can not start with character ' ' (position: START_TAG seen ...&lt;SMS_Zip_Code_Map_EUC__c>J &amp; ... @1:72405)</stateMessage>

Below 50 records It works fine.

Anyone has some idea?

Thanks in Advance,
Dhaval Panchal
Hi,
How can i fetch data from Salesforce for my Windows Store app using c# ?

Hello,

 

We are trying to dynamically invoke salesforce webservice without adding webreference in C#.Net. Our requirement is generate proxy  based on salesforce wsdl and return method name, service name and out put automatically.

 

I am expecting same like in following URL : http://www.crowsprogramming.com/archives/66

 

We are passing following web request in c#. Net code. 

====================================================

HttpWebRequest client = (HttpWebRequest)HttpWebRequest.Create("https://servername/services/wsdl/class/WebServiceName" + "?wsdl");
client.Credentials = new NetworkCredential("xyz@company.com", "test1uHN46qCxXomWqfRcEupLW9cg");
client.Method = "POST";

//client.ContentType = "application/x-www-form-urlencoded";
client.Headers.Add("Authorization" , "Basic " + loginResult.sessionId);
client.Headers.Add("SOAPAction", "");
client.ContentType = "text/xml;charset=\"utf-8\"";

 

HttpWebResponse wres = (HttpWebResponse)client.GetResponse();

XmlTextReader xmlreader = new XmlTextReader(wres.GetResponseStream());

serviceDescription = ServiceDescription.Read(xmlreader);

====================================================

We are getting following errors.

 

An error has occurred while opening external DTD 'http://www.w3.org/TR/html4/loose.dtd':  The remote server returned an error: (500) Internal Server Error."}

 

How can i resolve this error?

As a newbie with Chatter I had real problems figuring out the process to retrieve data so hopefully the following will help any other newbies trying to figure it out. Using the Developer Edition:

 

 

1. You will need an https domain where you will run your app which will make a request to your Chatter App
2. You will need to register a new sub domain within the Setup. I think it was under Domains. So you will have something like mydomain-dev-ed.my.salesforce.com

3. Create a Connected App (Create/Apps)
4. The Start URL will be the sub domain you created
5. Select the checkbox for Enable OAuth Settings
6. The callback url will be a path to your https domain on your server (ie https path/to/results.aspx
7. Put all the selected OAuth Scopes over to the right
8. Save

 

_____________________________________________________________________

_____________________________________________________________________

 

In the left side navigation you will see there is Manage Apps and Create/Apps

You will find info about your Connected App in both those locations.
You will need the Consumer Key, Consumer Secret and Callback Url (or redirect url)

You will now create two .net files which will reside on your server:

 

 

1. default.aspx
2. results.aspx

 

_______________________________________________________________________

 

The default.aspx will make the initial call to salesforce which will return a javascript string.
You will need to extract the relevant content from the string to use, which in turn will open a login page.

Once you have logged in, additional values will be passed back to your app.

 

______________________________________________________________________

______________________________________________________________________

 

In your default.aspx

 

 

 

string clientid = "this is the Consumer Key ";
string redirecturl = "https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=" + clientid + "&redirect_uri=" + redirecturl ;
var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "POST";
[Inside a try/catch put the following]
WebClient webClient = new WebClient();
webClient.Encoding = Encoding.UTF8;
result = webClient.DownloadString(uri);

string returnedString = result;

[The result is the string returned which you will need to extract the url contained within the string]
At this point you need to create a ClientScript which, when called, will load the login page.

String csname2 = "myscript";
Type cstype = this.GetType();
string jsScript = "<script>window.location.href ='" + Your_Extracted_Url + "'</script>";
ClientScriptManager cs = Page.ClientScript;
cs.RegisterClientScriptBlock(cstype, csname2, jsScript);

 

 

If you save the default.aspx, compiled your project and uploaded to your server then ran it, you would get the login page.

Something like:

 

https://login.salesforce.com/?ec=302&startURL=%2Fsetup%2Fsecur%2FRemoteAccessAuthorizationPage.apexp%3Fsource%3Dl86Hcy6qEKtWNqzXVErZDlmcRQs0D_HBE55MLVuP3x8t5wXkyHYyrVx2Xb5JoWzyVOJrnTqMMaWy_Sfomv.j1xklSQ67NPiEbdAN9Vn15MXpcuc7Tn4&sdtd=1


Now when you submit the login page, it is effectively going to your callback page you designated earlier, so now you have to add code to this file to retrieve the required data.

Result.aspx

[you can add your own try/catch and conditions]

 

string clientid = "same as previous";
string clientsecret = "your client secret";
string redirecturl = "same as previous";

string uri = "https://login.database.com/services/oauth2/token?grant_type=authorization_code&client_id=" + clientid + "&client_secret=" + clientsecret + "&redirect_uri=" + redirecturl + "&code=" + res + "&format=json";


var webRequest = (HttpWebRequest)WebRequest.Create(uri);
webRequest.Method = "POST";


if (webRequest.HaveResponse && response != null)
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
        string result = reader.ReadToEnd();
        JavaScriptSerializer ser = new JavaScriptSerializer();
        Dictionary<string,object> dict = ser.Deserialize<Dictionary<string, object>>(result);
        int dCount = 0;


       foreach (string strVal in dict.Values)
       {
         if (dCount == 6)
             {
                    string chatterApiUri = "https://SubdomainYouCreated.my.salesforce.com/services/data/v23.0/chatter/users/me";
                   var webRequestlogin = (HttpWebRequest)WebRequest.Create(chatterApiUri);
                  webRequestlogin.Headers.Add("Authorization", "OAuth "+ sToken);
                 webRequestlogin.Method = "GET";

                    using (var aresponse = webRequestlogin.GetResponse() as HttpWebResponse)
                    {
                                if (webRequestlogin.HaveResponse && response != null)
                               {
                                        using (var areader = new StreamReader(aresponse.GetResponseStream()))
                                       {
                                              string aresult = areader.ReadToEnd();
                                              lblresult.Text += "HERE IS YOUR RESULT " + aresult;
                                       }
                               }
                   }
 
       }
    }
  }
}

 

 

 

 

Your page on your server should display something like the following:

{"address":{"state":null,"country":"GB","street":null,"city":null,"zip":"EH3 5RT"},"email".......etc

 

 

It's a start but hopefully this will help because the documentation is shoddy.

  • October 03, 2013
  • Like
  • 1

When creating users via the REST api they do not get the email notification about it. I have found this post about the same issue with the SOAP api, which uses headers to enable emails, but I have not found documentation on how to do this with the REST api. How could I allow emails with the REST api?

  • September 12, 2013
  • Like
  • 0

Hi All,

 

for getting the 'Signed_request' header in each page do we need to set anything in the respective .net applications

 

thanks.

HI There,
I am trying to create Self service user. For some User its giving error that Invalid Password ! Passowrd does not contain user name.is it any way to change this password policy?
Thanks in advance
  • August 30, 2007
  • Like
  • 0
Attached is a C# snippet for sample code for validating email addresses within Sforce. This example gets email address information from Sforce and runs 10 tests on the email address. Email Validation provides fast and most accurate email address validation available and fully complies with Internet standards. Not only does DOTS for Email Validation fully recognize all forms of valid email addresses, but it can also verify the domain of the address and whether the user exists at that domain.

Email Validation performs the following escalating series of checks to verify an email address:

- Detect general format and syntax errors in email addresses
- Ensure addresses use a valid top level domain (e.g. .com, .net, .jp, .cc, etc.)
- Detect improper email address formats for common domains such as Hotmail and AOL
- Confirm that the email address has a valid DNS entry
- Confirm that the email address has a valid MX record
- Confirm that the domain can receive email (no message is actually sent)
- Confirm that the address can receive email (no message is actually sent)
- Determines whether the email address is provided for free (such as gmail, Hotmail, Yahoo...)
- Estimates whether the email address has been established twelve months or more.

All of these test can be performed in less that 1 second. Results for this example are written back to the description field within SForce.

Download sample code here:
http://www.serviceobjects.com/examples/salesforce/emailvalidation.zip

Web Site:
http://www.serviceobjects.com/products/

Happy Programming!