• Anshita Jain
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 7
    Replies
Hello!

I created a c# .net application where I first send a request for a login authentication token and get a service url, oathtoken, etc back. 

I am now trying to send a http get request to an apex class in my developers console and this is where I am stuck. I am sending a request to the service url with the oauthtoken. I append "/services/apexrest/Login/" to the service url and send the request to it. I am appending that because that is the uri I use to send a request to my class on workbench. However, this is not working and giving me a 404 error. What do I need to append to my service url to reach my apex class?
This is what my code is suppose to be doing: 
To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.


public class AccountHandler {

    public static Account insertNewAccount(String accName){
        if(accName!=''){    
            try{
                Account a = new Account(Name=accName);
                insert a;    
                return a;
            } catch(Exception e){
                
                return null;
            }
        } else {
        return null;
        }
    }
}

When I test it inside of the execute anonymous window, I input "insertNewAccount('abcd');". I get an error saying "Method does not exist or incorrect signature: void insertNewAccount(String) from the type anon"
 
Hello!
I have been trying to set up a username password Oauth following this link: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm

I set up a connected app and use its appropraite cliend id and secret. 
I am sending an HTTP post request through a local login .net app I created. I am sending all the appropriate information. However, my app returns a System.Net.WebException error 404. I tried sending a post request through https://openidconnect.herokuapp.com/ . This link says that my URI is unavailable. The URI that I am sending the request to is https://login.salesforce.com/services/oauth2/token. When I send a post request through Postman, it says "invalid client credentials", even though I am sure I am giving the right salesforce login credentials. 

Is this URI not available anymore? What am I doing wrong? 
This is what my code is suppose to be doing: 
To pass this challenge, create an Apex class that inserts a new account named after an incoming parameter. If the account is successfully inserted, the method should return the account record. If a DML exception occurs, the method should return null.


public class AccountHandler {

    public static Account insertNewAccount(String accName){
        if(accName!=''){    
            try{
                Account a = new Account(Name=accName);
                insert a;    
                return a;
            } catch(Exception e){
                
                return null;
            }
        } else {
        return null;
        }
    }
}

When I test it inside of the execute anonymous window, I input "insertNewAccount('abcd');". I get an error saying "Method does not exist or incorrect signature: void insertNewAccount(String) from the type anon"
 
Hello!
I have been trying to set up a username password Oauth following this link: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_understanding_username_password_oauth_flow.htm

I set up a connected app and use its appropraite cliend id and secret. 
I am sending an HTTP post request through a local login .net app I created. I am sending all the appropriate information. However, my app returns a System.Net.WebException error 404. I tried sending a post request through https://openidconnect.herokuapp.com/ . This link says that my URI is unavailable. The URI that I am sending the request to is https://login.salesforce.com/services/oauth2/token. When I send a post request through Postman, it says "invalid client credentials", even though I am sure I am giving the right salesforce login credentials. 

Is this URI not available anymore? What am I doing wrong?