[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ACMWXFPY0M7V4W8G9SATDN":3,"skill-same:01M6ACMWXFPY0M7V4W8G9SATDN":56},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":27,"publishedAt":29,"linkOnly":30,"markdownContent":31,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":6,"updatedAt":41,"install":42,"resources":55},"01M6ACMWXFPY0M7V4W8G9SATDN","manage-api-integration",null,"apache\u002Fofbiz-plugins","apache","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F47359?v=4","01M6AC83E6K4FDKK7HZ8WNMQKE","The Apache Software Foundation","01M6ACMJJ1Q4WYATY4GXZ2FAVD",178,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-api-integration\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[28],"manage api integration","2026-11-10 10:12:30",false,"\u003C!--\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements.  See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership.  The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License.  You may obtain a copy of the License at\n\nhttp:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied.  See the License for the\nspecific language governing permissions and limitations\nunder the License.\n-->\n\n---\nname: manage-api-integration\ndescription: Define and integrate REST APIs in OFBiz.\n---\n\n# Manage API Integration\n\nIntegration patterns for exposing OFBiz services via REST, and handling JSON responses.\n\n## REST API (framework REST API support)\n\nOFBiz uses framework REST API support to declaratively expose services.\n\nFor REST API design\u002Frefactoring, wrapper decisions, contract safety, and PWA\u002FAPI consumer compatibility, also read the `manage-rest-api` skill. This skill remains the broader integration guide for REST mechanics and controller JSON responses.\n\n### REST API Definitions\n\nREST endpoints are defined in `*.rest.xml` files located in the `api\u002F` directory of an OFBiz component. These files are discovered and registered by the framework REST API support; no explicit registration in `ofbiz-component.xml` is required.\n\n**Pattern for `*.rest.xml`:**\n```xml\n\u003Capi name=\"Example API\" path=\"example\" ...>\n    \u003Cresource name=\"Example\" path=\"examples\" ...>\n        \u003Coperation verb=\"GET\" path=\"\u002F{exampleId}\" service=\"findExampleById\" description=\"Get Example\">\n            \u003Cservice name=\"findExampleById\" \u002F>\n        \u003C\u002Foperation>\n        \u003Coperation verb=\"POST\" path=\"\u002Fcreate\" service=\"createExample\" description=\"Create Example\">\n            \u003Cservice name=\"createExample\" \u002F>\n        \u003C\u002Foperation>\n    \u003C\u002Fresource>\n\u003C\u002Fapi>\n```\n\n### Parameter Handling\n\nParameter mapping from REST requests to OFBiz services is **implicit**. The framework REST request handler extracts parameters from the request and maps them to service IN parameters whose names match.\n\n*   **Path Parameters:** Extracted from the URI based on placeholders in the `path` attributes (e.g., `{exampleId}`).\n*   **Query Parameters:** Extracted from the request URL.\n*   **Request Body:** For `POST`, `PUT`, and `PATCH` requests with `Content-Type: application\u002Fjson`, the JSON payload is automatically parsed into a map.\n\nAll extracted parameters are aggregated into a single context. The `ServiceRequestHandler` then uses `dispatcher.getDispatchContext().makeValidContext()` to select only those parameters that are defined as IN parameters for the target service.\n\nWhen implementing endpoint logic, prefer framework helpers that already exist in the target codebase or are being introduced in the same change. If a helper is not available yet, prefer service typing, `EntityQuery`, and small local logic.\n\n### Multi-Column Keys\nWhen a REST operation targets an OFBiz entity keyed by multiple columns, prefer sending the native key fields in the request body for create, update, and remove operations. This often allows the REST endpoint or client to call native OFBiz services directly instead of adding wrapper services only to decode a composite path ID.\n\nUse a stable composite REST ID only when the API shape truly needs a single identifier segment, such as a list\u002Fdetail link or a client-side row key. Keep composite ID encoding at the API edge and do not distort the underlying OFBiz entity or service model.\n\n### Security and Response Handling\n*   **Authentication:** Controlled by the `auth=\"true|false\"` attribute on the `\u003Coperation>` element.\n*   **Responses:** Services return their OUT parameters (excluding internal ones) as a JSON object. The response is automatically prefixed with `&&&START&&&` for XSSI protection.\n\n### Core Components\n- `OFBizApiConfig.java`: Scans and registers REST definitions.\n- `ServiceRequestHandler.java`: Dispatches REST requests to the OFBiz Service Dispatcher.\n\n## Direct Service REST Export\n\nOFBiz allows services to be exposed as REST APIs directly via attributes in the service definition.\n\n### Pattern:\n- **Attributes**: Set `export=\"true\"` and `action=\"VERB\"` (e.g., `action=\"GET\"`).\n- **Result**: The service becomes reachable as a REST endpoint (e.g., `\u002Frest\u002Fpublic\u002FfindProductById` or similar depending on framework REST configuration).\n\n```xml\n\u003Cservice name=\"findProductById\" engine=\"java\" auth=\"true\" export=\"true\" action=\"GET\" ...>\n    \u003Cattribute name=\"productId\" mode=\"IN\" type=\"String\" optional=\"false\"\u002F>\n\u003C\u002Fservice>\n```\n\n### Key Considerations:\n- **Simplicity**: No need for separate `rest.xml` or controller mappings.\n- **Contract-first**: The service signature defines the API request\u002Fresponse.\n- **Native OFBiz Types**: Prefer `Timestamp`, `BigDecimal`, `Double`, `Long`, and similar native types in service attributes so the Service Engine performs coercion before service logic runs.\n- **Auth**: Inherits service engine authentication rules.\n\n## JSON Responses\n\nFor standard controller-based AJAX\u002FAPI calls, use the `json` response type.\n\n### Controller Configuration\nIn `controller.xml`:\n```xml\n\u003Crequest-map uri=\"getJsonData\">\n    \u003Cevent type=\"service\" invoke=\"someService\"\u002F>\n    \u003Cresponse name=\"success\" type=\"request\" value=\"json\"\u002F>\n    \u003Cresponse name=\"error\" type=\"request\" value=\"json\"\u002F>\n\u003C\u002Frequest-map>\n```\n\n### Response Handling\n`CommonEvents.jsonResponseFromRequestAttributes` (or `CommonEvents.jsonResponseFromServiceResults` in some versions) processes the request attributes and writes a JSON object to the response.\n- **Security**: A `&&&START&&&` prefix is added to GET responses to prevent JSON hijacking (XSSI).\n\n## Security & Data Mapping\n\n- **Authentication**: REST API authentication depends on the framework REST configuration and the invoked service security.\n- **Permissions**: Every service invoked should have proper `permission-service` or `check-permission` logic.\n- **Data Mapping**: JSON\u002FXML fields must precisely match service IN attributes for automatic mapping. Use `ServiceUtil.getAndValidateParameters` pattern in custom Java events if manual mapping is needed.\n",{},"trunk","e488574ef5ae22181b9c1e5b9ebd327f9499ecfb","ai-agent-skills\u002Fmanage-api-integration",222,"https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins","https:\u002F\u002Fofbiz.apache.org\u002F","https:\u002F\u002Fgithub.com\u002Fapache","https:\u002F\u002Fwww.apache.org\u002F","2026-11-12 22:04:06",{"source":7,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add apache\u002Fofbiz-plugins --skill manage-api-integration",{"tool":48,"command":49},"bunx","bunx skills add apache\u002Fofbiz-plugins --skill manage-api-integration",{"tool":51,"command":52},"pnpm","pnpm dlx skills add apache\u002Fofbiz-plugins --skill manage-api-integration","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-api-integration\u002FSKILL.md",true,[],[57,64,71,78,85,92],{"skillNo":58,"name":59,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":29},"01M6ACQSN90YKJZ92MQ52D9R8H","prepush-readiness","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fprepush-readiness\u002FSKILL.md",[],[63],"prepush readiness",{"skillNo":65,"name":66,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":29},"01M6ACQPR1WRA751V4DXVC3AHF","manage-webapps","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-webapps\u002FSKILL.md",[],[70],"manage webapps",{"skillNo":72,"name":73,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":29},"01M6ACQMCX8Z7NY2CE08NCV6ND","manage-themes","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-themes\u002FSKILL.md",[],[77],"manage themes",{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":29},"01M6ACQHYN20AFWF6TKK4RGQ8A","manage-tests","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-tests\u002FSKILL.md",[],[84],"manage tests",{"skillNo":86,"name":87,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":29},"01M6ACQFRMW7R45YD3HRAXPGWF","manage-templates","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-templates\u002FSKILL.md",[],[91],"manage templates",{"skillNo":93,"name":94,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":29},"01M6ACQCSSDZQMD8VX2K3WRR93","manage-strategies","https:\u002F\u002Fgithub.com\u002Fapache\u002Fofbiz-plugins\u002Fblob\u002Ftrunk\u002Fai-agent-skills\u002Fmanage-strategies\u002FSKILL.md",[],[98],"manage strategies"]