+ Start a Discussion
LaurentDelcLaurentDelc 

Connection problem using Flex/Salesforce

Hi,

 

When I use the username and password with harcoded credentials, the connection works properly, but I cannot make the session_id work.

 

My account is a developer account.

 

 

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:salesforce="http://www.salesforce.com/" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#F3F3EC, #F3F3EC]" layout="horizontal" height="300" width="500" applicationComplete="login();"> <salesforce:Connection id="sfdc" /> <mx:Script> <![CDATA[ import com.salesforce.*; import com.salesforce.objects.*; import com.salesforce.results.*; import mx.collections.ArrayCollection; import mx.controls.Alert; import mx.collections.XMLListCollection; import mx.events.ListEvent; private function login():void { sfdc.login( new LoginRequest({ server_url : this.parameters.server_url, session_id : this.parameters.session_id, callback : new AsyncResponder(loginSuccess, loginFault) }) ); } private function loginSuccess(result:Object):void { Alert.show("yo yo"); } private function sfdcFailure(fault:Object):void { Alert.show(fault.faultstring); } private function loginFault(fault:Object):void { Alert.show("Could not log into SFDC: "+fault.fault.faultString,"Login Error"); } ]]> </mx:Script> <mx:Tree id="tree" dataProvider="{categoriesXmlData}" labelField="@name" showRoot="false" width="100%" height="100%" left="0" top="0" /></mx:Application>

 


 

 

In the login function part, if I remove the session_id parameter and replace it with the hardcoded cerdentials it works:

 

 

lr.username = "myLogin"; lr.password = "myPassword";

 

The session id is not empty but it doesn't work.

 

 

Has anybody ever encountered this issue?

 

Cheers 

Message Edited by LaurentDelc on 06-08-2009 08:53 AM
Best Answer chosen by Admin (Salesforce Developers) 
LaurentDelcLaurentDelc

IN fact I found a post regarding the same issue and the proposed solution worked for me. 

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=12373#M12373.

 

The conclusion is: Don't use the {!$Api.Session_ID} 

All Answers

ryan_marplesryan_marples
Where are you passing the server_url and session_id in from? Is it from a Visualforce page? If so, can you post that? I just tried it and it should work fine.
LaurentDelcLaurentDelc

Yes I use it from a visualforce page.

 

<apex:flash src="{!$Resource.tree}" width="500" height="300" flashvars="userId={!$User.Id}&session_id={!$Api.Session_ID}&server_url={!$Api.Partner_Server_URL_150}&appWorkflowId={!appWorkflowId}" />

 

 I work in a developer org. Could it be an issue?

 

LaurentDelcLaurentDelc

IN fact I found a post regarding the same issue and the proposed solution worked for me. 

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=12373#M12373.

 

The conclusion is: Don't use the {!$Api.Session_ID} 

This was selected as the best answer