• Andrey Harutyunyan
  • NEWBIE
  • 10 Points
  • Member since 2020

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

Hello,
Sorry for repeating the question.

I have this Apex class in my development edition account

@RestResource(urlMapping='/somevalue')
global with sharing class SomeValue extends Auth.ConnectedAppPlugin {
    @HttpGet
    global static String doGet() {
        return '444';
    }
}

Here is the screenshot - https://gyazo.com/58edea3a448a946406ba2e1c39c88b8b where you can see that code coverage is 100%. Maybe I did something wrong but Class summary is empty - https://gyazo.com/9eb006b12979ddd2bc3f15c059f78069 .

I added the class to my connected app as a Custom Connected App Handler - https://gyazo.com/b40da6eaefea584fd286ed62c2cfb147 .

When I login via oAuth using the account which I used to create the Apex class - the url 'https://myInstance.salesforce.com/services/apexrest/somevalue' gives me the correct value - '444'.

But when I login via oAuth (the same connected app) using other developer edition account - the url 'https://myAnothertherInstance.salesforce.com/services/apexrest/somevalue' gives 404 - Not found. In this case I send access token of the second account.

Seems there is not a namespace to use in the url.

I tried to add something as a Remote site url - but didn't help.

 

What could be wrong in my actions? Is something wrong in my codes?
Or what else should I do to make it working for all users which use the same connected app?

Thanks for your time to read this:

Hello,

I created a simple Apex class:
@RestResource(urlMapping='/somevalue')
global with sharing class SomeValue extends Auth.ConnectedAppPlugin {
    
    @HttpGet
    global static String doGet() {
        return '444';
    }
}
Also created a test for it:
@isTest
public class SomeValueTest {
	static testMethod void testHttpGet() {
    	String res = SomeValue.doGet();
        System.assertEquals('444', res);
    }
}

and it passed successfully - https://gyazo.com/58edea3a448a946406ba2e1c39c88b8b .
I also added it to my connected app as a Custom Connected App Handler - https://gyazo.com/b40da6eaefea584fd286ed62c2cfb147 .
I enabled all the scopes (think that isn't necessary).

When I login via oAuth using the account which I used to create the Apex class - the url 'https://myInstance.salesforce.com/services/apexrest/somevalue' gives me the correct value - '444'.
But when I login via oAuth (the same connected app) using other developer edition account - the url 'https://myAnothertherInstance.salesforce.com/services/apexrest/somevalue' gives 404 - Not found.

What else should I do to make it working for all users?

 

PS
I do this to know what should I do for my real Apex class.

List<Event> EventsList = [SELECT Id FROM Event WHERE WhoId = :contactId];
for(Event E : EventsList){
    // the line below gives an error about invalid method. what code should I write?
    // E.setWhatId(accountId);
}
I need to set whatId of events and tasks of a contact who just was been converted from a lead to a contact skipping opportunity creation. But couldn't find according info to do that.

Thanks,
Andrey

Hello,
Sorry for repeating the question.

I have this Apex class in my development edition account

@RestResource(urlMapping='/somevalue')
global with sharing class SomeValue extends Auth.ConnectedAppPlugin {
    @HttpGet
    global static String doGet() {
        return '444';
    }
}

Here is the screenshot - https://gyazo.com/58edea3a448a946406ba2e1c39c88b8b where you can see that code coverage is 100%. Maybe I did something wrong but Class summary is empty - https://gyazo.com/9eb006b12979ddd2bc3f15c059f78069 .

I added the class to my connected app as a Custom Connected App Handler - https://gyazo.com/b40da6eaefea584fd286ed62c2cfb147 .

When I login via oAuth using the account which I used to create the Apex class - the url 'https://myInstance.salesforce.com/services/apexrest/somevalue' gives me the correct value - '444'.

But when I login via oAuth (the same connected app) using other developer edition account - the url 'https://myAnothertherInstance.salesforce.com/services/apexrest/somevalue' gives 404 - Not found. In this case I send access token of the second account.

Seems there is not a namespace to use in the url.

I tried to add something as a Remote site url - but didn't help.

 

What could be wrong in my actions? Is something wrong in my codes?
Or what else should I do to make it working for all users which use the same connected app?

Thanks for your time to read this:

Hello,

I created a simple Apex class:
@RestResource(urlMapping='/somevalue')
global with sharing class SomeValue extends Auth.ConnectedAppPlugin {
    
    @HttpGet
    global static String doGet() {
        return '444';
    }
}
Also created a test for it:
@isTest
public class SomeValueTest {
	static testMethod void testHttpGet() {
    	String res = SomeValue.doGet();
        System.assertEquals('444', res);
    }
}

and it passed successfully - https://gyazo.com/58edea3a448a946406ba2e1c39c88b8b .
I also added it to my connected app as a Custom Connected App Handler - https://gyazo.com/b40da6eaefea584fd286ed62c2cfb147 .
I enabled all the scopes (think that isn't necessary).

When I login via oAuth using the account which I used to create the Apex class - the url 'https://myInstance.salesforce.com/services/apexrest/somevalue' gives me the correct value - '444'.
But when I login via oAuth (the same connected app) using other developer edition account - the url 'https://myAnothertherInstance.salesforce.com/services/apexrest/somevalue' gives 404 - Not found.

What else should I do to make it working for all users?

 

PS
I do this to know what should I do for my real Apex class.

List<Event> EventsList = [SELECT Id FROM Event WHERE WhoId = :contactId];
for(Event E : EventsList){
    // the line below gives an error about invalid method. what code should I write?
    // E.setWhatId(accountId);
}
I need to set whatId of events and tasks of a contact who just was been converted from a lead to a contact skipping opportunity creation. But couldn't find according info to do that.

Thanks,
Andrey