CCD-102 practice question 11 of 30

A developer wants to use an external application to manage their stores information (such as opening hours, and so on), and see their changes in their B2C Commerce Staging instance aas son as they are saved. What is the appropriate technique the developer should perform to allow the merchant to create a new store in this scenario?

Full set: 206 questions
Answer options
A: A POST request to the Stores Data OCAPI.
B: A PUT request to the Stores Data OCAPI. Correct answer
C: A PATCH request to the Stores Data OCAPI.
D: An UPDATE request to the Stores Data OCAPI. Siempre que sea un objeto standard será put en vez de post
Correct Answer:
B. A PUT request to the Stores Data OCAPI.
Explanation

In the Salesforce B2C Commerce Open Commerce API (OCAPI), the standard method for creating a new resource, such as a store, is by using an HTTP PUT request. The client application must specify the unique identifier for the new store in the request URI (e.g., PUT /stores/{storeid}). This design choice makes the creation operation idempotent, meaning that making the same PUT request multiple times will result in the same state without creating duplicate resources. The API uses this single PUT method to handle both the creation of a new store and the complete replacement (update) of an existing one.

References

1. Salesforce B2C Commerce Cloud OCAPI Documentation: The official documentation for the Stores Data API resource explicitly defines the HTTP methods.

Resource: stores

Endpoint: /stores/{storeid}

Method: PUT

Description: "Creates or updates a store. The store is created if it does not exist. The store is updated if it already exists."

Source: Salesforce Developer Center

B2C Commerce Cloud OCAPI 23.10 Documentation

Data API

Resources: stores.

2. Roy T. Fielding

"Architectural Styles and the Design of Network-based Software Architectures" (Ph.D. dissertation

University of California

Irvine): This foundational text on REST architecture distinguishes between PUT and POST.

Section 5.2.1.2

"PUT": "The PUT method requests that the enclosed entity be stored under the supplied Request-URI... If the Request-URI refers to an already existing resource

the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. If the Request-URI does not point to an existing resource... the origin server can create the resource with that URI." This supports the use of PUT for creation when the client defines the resource URI.

DOI: https://www.ics.uci.edu/~fielding/pubs/dissertation/restarchstyle.htm#sec5212

Scroll to Top