Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

IBM C1000-138 Exam - Topic 3 Question 8 Discussion

Posted by Kris on Sep 15, 2024 at 09:52 AM

What is correct about using context variables in Gatewayscript policies?

Suggested Answer: A

Setting Context Variables: In Gatewayscript policies, thecontext.setfunction is used to set context variables. The syntaxcontext.set('my.vars.amount', 100)creates a JSON structure wheremy.varsis an object containing the keyamountwith the value100.

JSON Structure: This method of setting context variables generates a JSON structure, which is a common format for data interchange in APIs. The resulting structure would be{ 'my.vars': { 'amount': 100 } }.

Usage in Policies: This approach allows for easy manipulation and access to variables within the GatewayScript, facilitating dynamic API behavior based on the context.

Documentation Reference: According to the IBM Certified Solution Implementer - API Connect v10.0.3 documentation, usingcontext.setin this manner is the correct way to generate the specified JSON structure1.

1:IBM Certified Solution Implementer - API Connect v10.0.3 Documentation


Get Premium C1000-138 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
35 comments · newest first
LA
Lazaro 11 months ago
C is definitely right, I've used that before!
AM
Ammie 11 months ago
Wait, does D really update the request status?
KE
Kerry 11 months ago
B seems off, not all vars are in XML.
KE
Kenneth 11 months ago
Totally agree with A!
ST
Stevie 12 months ago
A is correct, it creates a nested object.
RE
Reena 12 months ago
I’m a bit confused about option D; I thought the request object status code was updated differently.
RE
Rebecka 12 months ago
I practiced a question similar to option C, and I believe it does update the message status code correctly.
LU
Lucille 1 year ago
I remember something about context variables being stored in a tree, but I can't recall if it's specifically XML.
ME
Mendy 1 year ago
I think option A sounds familiar, but I'm not entirely sure if it generates that exact structure.
HA
Hassie 1 year ago
Alright, let me think this through step-by-step. Option A sounds right, since that's the syntax for setting a context variable. For the other options, I'll need to carefully consider how the context variables interact with the different objects in Gatewayscript.
MI
Mira 1 year ago
I'm a bit confused by this question. The context variables in Gatewayscript can be a bit tricky to remember. I'll need to review the documentation to make sure I understand the differences between the request and message objects.
DO
Donette 1 year ago
I've worked with context variables before, so I'm pretty confident about this one. I'm pretty sure option C is correct, since that's how you'd update the status code of the message object.
DA
Daniel 1 year ago
Okay, let's see. I think option A is correct, since that's how you'd set a context variable. But I'm not sure about the other options - I'll have to double-check the details on those.
JO
Joseph 1 year ago
Hmm, this looks like a tricky one. I'll need to carefully read through the options and think about how context variables work in Gatewayscript policies.
KA
Karl 2 years ago
I always get these context variable questions mixed up. Maybe I should just start guessing randomly.
LU
Ludivina 2 years ago
↳ replying to Karl
B) All API context variables are saved in an XML tree.
LI
Lisbeth 2 years ago
↳ replying to Karl
C) context.message.statuscode = '200 Success' updates the status code of the message object.
EA
Earnestine 2 years ago
↳ replying to Karl
A) context.set('my.vars.amount', 100) generates { my.vars: { amount: 100 } }
BE
Berry 2 years ago
Wait, so we can't use context.request.statuscode? That's going to make my life a lot harder.
HU
Hubert 2 years ago
↳ replying to Berry
C) context.message.statuscode = '200 Success' updates the status code of the message object.
LA
Lavonna 2 years ago
↳ replying to Berry
B) All API context variables are saved in an XML tree.
ER
Erinn 2 years ago
↳ replying to Berry
A) context.set('my.vars.amount', 100) generates { \'my.vars\': { \'amount\': 100 } }
MI
Michel 2 years ago
Hmm, that makes sense. I see your point now.
CI
Ciara 2 years ago
I disagree, I believe C) is correct because it updates the status code of the message object.
MI
Michel 2 years ago
I think A) is correct because it shows how to set a context variable.
FE
Felicitas 2 years ago
This exam question is a piece of cake! I could answer it in my sleep.
BU
Bulah 2 years ago
Option D is incorrect. The context.request.statuscode property does not exist, it should be context.message.statuscode.
NI
Nickole 2 years ago
↳ replying to Bulah
Option D is incorrect. The context.request.statuscode property does not exist, it should be context.message.statuscode.
CA
Carin 2 years ago
↳ replying to Bulah
C) context.message.statuscode = '200 Success' updates the status code of the message object.
TR
Trevor 2 years ago
↳ replying to Bulah
B) All API context variables are saved in an XML tree.
AN
Angelo 2 years ago
↳ replying to Bulah
A) context.set('my.vars.amount', 100) generates { \'my.vars\': { \'amount\': 100 } }
ME
Merlyn 2 years ago
Option C is the correct answer. The context.message.statuscode property allows you to update the status code of the message object.
CA
Carlee 2 years ago
↳ replying to Merlyn
A) context.set('my.vars.amount', 100) generates { \'my.vars\': { \'amount\': 100 } }
BR
Brandon 2 years ago
↳ replying to Merlyn
C) context.message.statuscode = '200 Success' updates the status code of the message object.
KA
Kanisha 2 years ago
Option A is also correct. The context.set() function allows you to set context variables as key-value pairs.
0/2000 characters

Save Cancel