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??

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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