cancel
Showing results for 
Search instead for 
Did you mean: 

Quote 2.0: Post requests of a Rest Client

Lola_234
Explorer
0 Kudos

Dear SAP Community,

I am currently sending a post request with the following command in an if loop : 

RestClient.Post(url, data, headers) . The paramaters url, data and headers are already specified . The problem is that i have further commands after sending the request from the CPQ system in the if loop, that I want to execute. Once The RestClient is run, the further requests are no longer executed. 

Does anyone have any suggestions or idea, where or how I can solve such an issue ?

Best regards 

Lola

 

 

 

Fancy_Zou
Product and Topic Expert
Product and Topic Expert
0 Kudos
May you please post the complete IronPython codes that you wrote for loop logic?

Accepted Solutions (0)

Answers (2)

Answers (2)

Fancy_Zou
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Cyrine,

It seems like you are attempting to include error messages in the event of a failed API call. If this is the case, it is likely that the scenario will occur when the RestClient.Post execution encounters errors such as HTTP 400/500 errors. In order to handle these potential errors, you will need to use a "try" command to catch them. Otherwise, the script will halt execution when an error occurs.

Sample syntax: 

try:
response = RestClient.Post(url, data, headers)

except Exception as e:
context.Quote.AddMessage("message text", MessageLevel.Error, True)

When it comes to "loop" logic, you will need to incorporate "if" logic within a "for" loop.

Best Regards

Fancy

Lola_234
Explorer
0 Kudos

Hi Fancy,

The command context.Quote.AddMessage("Message text", MessageLevel.Error, True) is not considered as an error handling command , it should be actually executed after the sucessful call of the API to inform the user that the post request was sucessful. That's why i am not getting why the post request is blocking any further commands.

Best regards

Lola

 

Fancy_Zou
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi, please incorporate "if" logic within a "for" loop. "if" is only a criteria judgement, not a loop.
Lola_234
Explorer
0 Kudos

Hi Fancy, 

if myvariable  == myvalue:
response = RestClient.Post(url, data, headers)
context.Quote.AddMessage("message text", MessageLevel.Error, True)

The post request is running perfectly but the next command won't be executed.

Best regards

Lola