@@ -338,6 +338,44 @@ See the `b2c-cli:b2c-scapi-custom` skill for more status options.
338338| Endpoint not appearing | Verify cartridge is in site's cartridge path, re-activate code version |
339339| 404 on requests | Endpoint not registered or wrong URL path |
340340
341+ # # Testing Custom APIs
342+
343+ Test your Custom API endpoints using curl after deployment.
344+
345+ # ## Get a Shopper Token (Private Client)
346+
347+ Using a private SLAS client with client credentials grant :
348+
349+ ` ` ` bash
350+ # Set your credentials
351+ SHORTCODE="your-short-code"
352+ ORG="f_ecom_xxxx_xxx"
353+ SLAS_CLIENT_ID="your-client-id"
354+ SLAS_CLIENT_SECRET="your-client-secret"
355+ SITE="RefArch"
356+
357+ # Get access token
358+ TOKEN=$(curl -s "https://$SHORTCODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/token" \
359+ -u "$SLAS_CLIENT_ID:$SLAS_CLIENT_SECRET" \
360+ -d "grant_type=client_credentials&channel_id=$SITE" | jq -r '.access_token')
361+
362+ echo $TOKEN
363+ ` ` `
364+
365+ # ## Call Your Custom API
366+
367+ ` ` ` bash
368+ # Call the Custom API endpoint
369+ curl -s "https://$SHORTCODE.api.commercecloud.salesforce.com/custom/my-api/v1/organizations/$ORG/my-endpoint?siteId=$SITE" \
370+ -H "Authorization: Bearer $TOKEN" | jq
371+ ` ` `
372+
373+ # ## Testing Tips
374+
375+ - Use `b2c slas client list` to find existing SLAS clients
376+ - Use `b2c slas client create --scopes "c_my_scope,sfcc.shopper-*"` to create a test client
377+ - Check logs with `b2c webdav get` from the `logs` root if requests fail
378+
341379# # HTTP Methods Supported
342380
343381- GET (no transaction commits)
@@ -376,11 +414,50 @@ var service = LocalServiceRegistry.createService('my.external.api', {
376414var result = service.call({ token: 'my-token' });
377415` ` `
378416
379- # ## Quick Reference
417+ # ## Inline services.xml Example
418+
419+ For simple HTTP services :
420+
421+ ` ` ` xml
422+ <?xml version="1.0" encoding="UTF-8"?>
423+ <services xmlns="http://www.demandware.com/xml/impex/services/2014-09-26">
424+
425+ <service-credential service-credential-id="my.external.api">
426+ <url>https://api.example.com/v1</url>
427+ </service-credential>
428+
429+ <service-profile service-profile-id="my.external.api.profile">
430+ <timeout-millis>5000</timeout-millis>
431+ <rate-limit-enabled>false</rate-limit-enabled>
432+ <rate-limit-calls>0</rate-limit-calls>
433+ <rate-limit-millis>0</rate-limit-millis>
434+ <cb-enabled>true</cb-enabled>
435+ <cb-calls>5</cb-calls>
436+ <cb-millis>10000</cb-millis>
437+ </service-profile>
438+
439+ <service service-id="my.external.api">
440+ <service-type>HTTP</service-type>
441+ <enabled>true</enabled>
442+ <log-prefix>MYAPI</log-prefix>
443+ <comm-log-enabled>true</comm-log-enabled>
444+ <force-prd-enabled>false</force-prd-enabled>
445+ <mock-mode-enabled>false</mock-mode-enabled>
446+ <profile-id>my.external.api.profile</profile-id>
447+ <credential-id>my.external.api</credential-id>
448+ </service>
449+
450+ </services>
451+ ` ` `
452+
453+ **Common XML element name mistakes:**
454+ - Use `service-credential-id`, NOT `id`
455+ - Use `user-id`, NOT `user`
456+ - Use `force-prd-enabled`, NOT `force-prd-comm-log-enabled`
457+
458+ Import with : ` b2c job import ./my-services-folder`
380459
381- To import a service configuration :
382- 1. Create `services.xml` following the `b2c:b2c-webservices` skill patterns
383- 2. Import : ` b2c job import ./my-services-folder`
460+ See `b2c:b2c-webservices` skill for complete schema documentation, or run `b2c docs schema services` for the XSD.
384461
385462# # Related Skills
386463
0 commit comments