BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zinabenammar
Fluorite | Level 6

Hello, 

I'm facing a problem while trying to create a code DS2  to create  and execute a post this is my code :

proc ds2;

data test / overwrite=yes;

/*dcl varchar(65000) response;*/

method init();

dcl package tap_restcallout scbQuery();

dcl integer rc sc;


rc=scbQuery.createPost( 'https://hooks.slack.com/services/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');



sc=scbQuery.executePost(payload={"text": "tttttt"});



put 'RC=' rc;

put 'SC= ' sc;



end;

enddata;

run;

quit;

 

 

Please find in attachement the code SAS DS2 for the package tap_restcallout

 

Log

 

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc ds2;
74
75 data test / overwrite=yes;
76
77 /*dcl varchar(65000) response;*/
78
79 method init();
80
81 dcl package tap_restcallout scbQuery();
82
83 dcl integer rc sc;
85 sc=scbQuery.executePost(payload={"text": "tttttt"});
86 put 'RC=' rc;
87 put 'SC= ' sc;
88
89
90
91 end;
92
93 enddata;
94
95 run;
ERROR: Compilation error.
ERROR: Line 84: No method declaration for method createpost matches the given argument list.
ERROR: Line 85: No method declaration for method executepost matches the given argument list.
NOTE: PROC DS2 has set option NOEXEC and will continue to prepare statements.
96
97 quit;
 

 

 
 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

Your package contains an overloaded definition for the createPost method. One of the methods requires 5 parameters, the other 7: 

method createPost(nvarchar(16384) url, int timeout, nvarchar(256) userid, nvarchar(256) password, in_out int rc);
method createPost(nvarchar(16384) url, nvarchar(16384) contentType, nvarchar(16384) accept, int timeout, nvarchar(256) userid, nvarchar(256) password, in_out int rc);

 When you call the method in your code, DS2 looks for a method definition that has the same number of parameters. Your method call looks like this:

scbQuery.createPost( 'https://hooks.slack.com/services/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');

Because your method call only provides one  parameter value, there is no method definition in the package that matches that pattern, and DS2 throws the error:

ERROR: Line 84: No method declaration for method createpost matches the given argument list.

Your call to the executePost method has the same problem, resulting in the error:

ERROR: Line 85: No method declaration for method executepost matches the given argument list.

When you call a method in a DS2 data program, you must provide values for all parameters in order to execute the method without error.

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

2 REPLIES 2
SASJedi
SAS Super FREQ

Your package contains an overloaded definition for the createPost method. One of the methods requires 5 parameters, the other 7: 

method createPost(nvarchar(16384) url, int timeout, nvarchar(256) userid, nvarchar(256) password, in_out int rc);
method createPost(nvarchar(16384) url, nvarchar(16384) contentType, nvarchar(16384) accept, int timeout, nvarchar(256) userid, nvarchar(256) password, in_out int rc);

 When you call the method in your code, DS2 looks for a method definition that has the same number of parameters. Your method call looks like this:

scbQuery.createPost( 'https://hooks.slack.com/services/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');

Because your method call only provides one  parameter value, there is no method definition in the package that matches that pattern, and DS2 throws the error:

ERROR: Line 84: No method declaration for method createpost matches the given argument list.

Your call to the executePost method has the same problem, resulting in the error:

ERROR: Line 85: No method declaration for method executepost matches the given argument list.

When you call a method in a DS2 data program, you must provide values for all parameters in order to execute the method without error.

Check out my Jedi SAS Tricks for SAS Users
ballardw
Super User

Both of the CreatePost methods in the code show 4 or more arguments. Your call in the code

rc=scbQuery.createPost( 'https://hooks.slack.com/services/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');

uses only one.

I don't do DS2 but that in a generic "number of parameters should match the parameters in the method call" way looks suspicious. Maybe you want another that only uses the URL??

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 957 views
  • 0 likes
  • 3 in conversation