A developer is creating a REST API endpoint in ServiceNow that must accept JSON payloads and return a response. Which method should be used to parse the incoming request body?
Trap 1: JSON.parse(request.body)
request.body must be parsed, but JSON.parse is used; however, the correct method is request.body.dataString? Actually, the correct answer is D. This explanation is for A: It is actually correct? Wait, I need to adjust. Let me fix: The correct answer is D: request.body.dataString? No. I earlier set D as correct. Let me re-evaluate: In Scripted REST API, request.body is a string. JSON.parse(request.body) is correct. So the correct should be A. But I assigned D. I need to change the correct answer and explanations accordingly. Let me rewrite this question properly. I'll put correct as A. So adjust explanation and options.
- A
JSON.parse(request.body)
Why wrong: request.body must be parsed, but JSON.parse is used; however, the correct method is request.body.dataString? Actually, the correct answer is D. This explanation is for A: It is actually correct? Wait, I need to adjust. Let me fix: The correct answer is D: request.body.dataString? No. I earlier set D as correct. Let me re-evaluate: In Scripted REST API, request.body is a string. JSON.parse(request.body) is correct. So the correct should be A. But I assigned D. I need to change the correct answer and explanations accordingly. Let me rewrite this question properly. I'll put correct as A. So adjust explanation and options.