• Sabina Ismailova 1
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hello everybody, help me please!
I finished developing integration "MyApp->Salesforce". I want to make my app global and put it on App Exchange. In the end I want to get something like that: https://appexchange.salesforce.com/listingDetail?listingId=a0N30000001rmjpEAA  - when somebody presses "Install" it redirects to my website.
I'm using .NET application with Oauth. I read that I need to create a package to make app global. So here I got my app:
User-added image
And I'm trying to make a package, but there's no my app in apps list. Also my package is not "managed" by default and I can't change check there.
User-added image
Help me please, maybe I'm missing something? I really don't get it.
 
I'm trying to connect my asp.net REST api to salesforce. I'm succesfully going through authentification, but when I start to send POST requests, I'm getting an error

{"errorCode":"INVALID_SESSION_ID","message":"Session expired or invalid"}

Here is my POST request:
       
//SFServerUrl = "https://na17.salesforce.com/services/";
       //url = "data/v28.0/sobjects/Account";

                ASCIIEncoding ascii = new ASCIIEncoding();
                byte[] postBytes = ascii.GetBytes(postBody);
                HttpWebRequest request = WebRequest.Create(Globals.SFServerUrl + url) as HttpWebRequest;
                request.Method = "POST";
                request.ContentType = "application/json";
                request.ContentLength = postBytes.Length;
                Stream postStream = request.GetRequestStream();
                postStream.Write(postBytes, 0, postBytes.Length);

                HttpCookie cookie = HttpContext.Current.Request.Cookies[Globals.SFCookie];
                var ticket = FormsAuthentication.Decrypt(cookie.Value);
                string authToken = ticket.UserData;
                request.Headers.Add("Authorization", "Bearer " + authToken);
                postStream.Close();

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                StringBuilder sb = new StringBuilder();
                byte[] buf = new byte[8192];
                Stream resStream = response.GetResponseStream();
                string tempString = null;
                int count = 0;
                do
                {
                    count = resStream.Read(buf, 0, buf.Length);
                    if (count != 0)
                    {
                        tempString = Encoding.ASCII.GetString(buf, 0, count);
                        sb.Append(tempString);
                    }
                }
                while (count > 0);
                return new Tuple<bool, string>(true, sb.ToString());
When I'm trying to send GET request - I recieve 200 response.
Also, I've tried to send a POST Request with the same token from Simple Rest Client and it get's 200 response. I tried to change my "Authorization : Bearer" Header to "Authorization : Oauth", but nothing changed.
I also tried to catch this error, get refresh token and send a request again with refreshed token, but nothing changed.
Please, help me with this!
I'm trying to connect my asp.net REST api to salesforce. I'm succesfully going through authentification, but when I start to send POST requests, I'm getting an error

{"errorCode":"INVALID_SESSION_ID","message":"Session expired or invalid"}

Here is my POST request:
       
//SFServerUrl = "https://na17.salesforce.com/services/";
       //url = "data/v28.0/sobjects/Account";

                ASCIIEncoding ascii = new ASCIIEncoding();
                byte[] postBytes = ascii.GetBytes(postBody);
                HttpWebRequest request = WebRequest.Create(Globals.SFServerUrl + url) as HttpWebRequest;
                request.Method = "POST";
                request.ContentType = "application/json";
                request.ContentLength = postBytes.Length;
                Stream postStream = request.GetRequestStream();
                postStream.Write(postBytes, 0, postBytes.Length);

                HttpCookie cookie = HttpContext.Current.Request.Cookies[Globals.SFCookie];
                var ticket = FormsAuthentication.Decrypt(cookie.Value);
                string authToken = ticket.UserData;
                request.Headers.Add("Authorization", "Bearer " + authToken);
                postStream.Close();

                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                StringBuilder sb = new StringBuilder();
                byte[] buf = new byte[8192];
                Stream resStream = response.GetResponseStream();
                string tempString = null;
                int count = 0;
                do
                {
                    count = resStream.Read(buf, 0, buf.Length);
                    if (count != 0)
                    {
                        tempString = Encoding.ASCII.GetString(buf, 0, count);
                        sb.Append(tempString);
                    }
                }
                while (count > 0);
                return new Tuple<bool, string>(true, sb.ToString());
When I'm trying to send GET request - I recieve 200 response.
Also, I've tried to send a POST Request with the same token from Simple Rest Client and it get's 200 response. I tried to change my "Authorization : Bearer" Header to "Authorization : Oauth", but nothing changed.
I also tried to catch this error, get refresh token and send a request again with refreshed token, but nothing changed.
Please, help me with this!