Dears, I hope you are doing well,
I am using an on-premise Apigee and I have a scenario in which I would like to set monetization on one proxy containing one API, but I have a service callout policy.
How can I check if the callout service returns 404 and the current API returns 200 then calculate the transaction?
I used many ways and solutions but I am stuck can I use costume JS code that will check both of the codes and then add a new floe variable named nabeahCode its value is '690' then check it inside the criteria like below?
Solved! Go to Solution.
I don't have access to an Apigee OPDK or an Edge installation, but I want to make sure I understand your question.
I think you are asking how to indicate a successful monetization transaction within an Proxy, correct?
So for example, your criteria is:
1. The service callout must return a 404.
2. The API must return a 200
If both of these are True, then this transaction should be treated as a valid API request and be counted/included in monetization.
Is that correct?
Additionally, you have tried other solutions, but have not been able to get those to work. I'm curious to know what other solutions you have tried.
Now you are attempting to use a custom JavaScript (JS) policy that populates a flow variable that includes a value of 690 when both the Service Callout returns 404 and the API returns 200. Your Transaction Recording Policy refers to your flow variable and that flow variable is set to 690 in your JS policy and you are saying that it still does not work?
I think you have the right idea. Yes, you can use a JS policy to set your flow variable to `690` if your criteria is met. Your transaction recording policy refers to your flow variable for the status attribute. Based on what I see in your post, it seems like it is correct and it should work. If you could provide some more information we might be able to provide a better response.
You don't have to use a JS policy; you should be able to accomplish the same thing with an AssignMessage policy and a condition on that policy. Something like what I have shown below. Then you refer to the flow variable in your transaction recording policy. You probably also want to set a default value for this flow variable.
<AssignMessage name="AM-monetizationok" >
<AssignVariable>
<Name>monetizationStatus</Name>
<Value>OK</Value>
</AssignVariable>
</AssignMessage>
<Step>
<Name>AM-monetizationok</Name>
<Condition>calloutResponse.status.code == "404" and response.status.code == "200"</Condition>
</Step>
Hi @Amer-Hijazi, thanks for posting your question.
We’re currently looking into it, sorry for the issues that this may cause.
In the meantime, perhaps this discussion may be of assitance: https://www.googlecloudcommunity.com/gc/Apigee/Does-APIGEE-X-eval-org-charges-anything/m-p/780405#M7...
I don't have access to an Apigee OPDK or an Edge installation, but I want to make sure I understand your question.
I think you are asking how to indicate a successful monetization transaction within an Proxy, correct?
So for example, your criteria is:
1. The service callout must return a 404.
2. The API must return a 200
If both of these are True, then this transaction should be treated as a valid API request and be counted/included in monetization.
Is that correct?
Additionally, you have tried other solutions, but have not been able to get those to work. I'm curious to know what other solutions you have tried.
Now you are attempting to use a custom JavaScript (JS) policy that populates a flow variable that includes a value of 690 when both the Service Callout returns 404 and the API returns 200. Your Transaction Recording Policy refers to your flow variable and that flow variable is set to 690 in your JS policy and you are saying that it still does not work?
I think you have the right idea. Yes, you can use a JS policy to set your flow variable to `690` if your criteria is met. Your transaction recording policy refers to your flow variable for the status attribute. Based on what I see in your post, it seems like it is correct and it should work. If you could provide some more information we might be able to provide a better response.
You don't have to use a JS policy; you should be able to accomplish the same thing with an AssignMessage policy and a condition on that policy. Something like what I have shown below. Then you refer to the flow variable in your transaction recording policy. You probably also want to set a default value for this flow variable.
<AssignMessage name="AM-monetizationok" >
<AssignVariable>
<Name>monetizationStatus</Name>
<Value>OK</Value>
</AssignVariable>
</AssignMessage>
<Step>
<Name>AM-monetizationok</Name>
<Condition>calloutResponse.status.code == "404" and response.status.code == "200"</Condition>
</Step>
@williamssean and @Hilda_Arteaga Thank you for your time and effort after 3 days I found the solution to the problem that I am using $ sing within the flow variable once I removed it then everything worked fine as expected.
what I did in JS if these conditions are correct
calloutResponse.status.code == "404" and response.status.code == "200"
If the above condition is successful inside the JS success, I create a flow variable named nabeahCode = '204'. if it is made then the transaction will be calculated. I used the "204" code in the "criteria" but I think as You mentioned the "OK" is better 👍
Thanks a lot for your support
Hi @Amer-Hijazi
Thanks for taking the time to share the status and the solution with us.
I’m glad to hear you have found the workaround, also thanks for passing on the tips. I’m sure this will help others that encounter a similar situation.
You’re indeed the ones who makes this community better for everyone
And lastly but not least, thanks for jumping in @williamssean
Hello guys, sorry for jumping in, I'm facing an issue that I configured the required monetization configurations and the developer affected, but I can't access the mint flow variables at all, I'm trying to access them in the post client flow with a service callout policy
any help on that ?
Can you post this as a new question and include me? This one is marked as solved.
Done, kindly need your support.
Dear @williamssean you can find my question here https://www.googlecloudcommunity.com/gc/Apigee/issue-trying-to-access-the-mint-flow-variables/td-p/8...