5.1 KiB
SAP Integration Testing Guide
Postman Testing
1. Testing IO Validation API
Endpoint: GET /api/v1/dealer-claims/:requestId/io
Method: GET
Headers:
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
Note: The CSRF error in Postman is likely coming from SAP, not our backend. Our backend doesn't have CSRF protection enabled.
2. Testing Budget Blocking API
Endpoint: PUT /api/v1/dealer-claims/:requestId/io
Method: PUT
Headers:
Authorization: Bearer <your_jwt_token>
Content-Type: application/json
Body:
{
"ioNumber": "600060",
"ioRemark": "Test remark",
"availableBalance": 1000000,
"blockedAmount": 500,
"remainingBalance": 999500
}
3. Direct SAP API Testing in Postman
If you want to test SAP API directly (bypassing our backend):
IO Validation
- URL:
https://RENOIHND01.Eichergroup.com:1443/sap/opu/odata/sap/ZFI_BUDGET_CHECK_API_SRV/GetSenderDataSet?$filter=IONumber eq '600060'&$select=Sender,ResponseDate,GetIODetailsSet01&$expand=GetIODetailsSet01&$format=json - Method: GET
- Authentication: Basic Auth
- Username: Your SAP username
- Password: Your SAP password
- Headers:
Accept: application/jsonContent-Type: application/json
Budget Blocking
- URL:
https://RENOIHND01.Eichergroup.com:1443/sap/opu/odata/sap/ZFI_BUDGET_BLOCK_API_SRV/RequesterInputSet - Method: POST
- Authentication: Basic Auth
- Username: Your SAP username
- Password: Your SAP password
- Headers:
Accept: application/jsonContent-Type: application/json
- Body:
{
"Request_Date_Time": "2025-08-29T10:51:00",
"Requester": "REFMS",
"lt_io_input": [
{
"IONumber": "600060",
"Amount": "500"
}
],
"lt_io_output": [],
"ls_response": []
}
Common Errors and Solutions
1. CSRF Token Validation Error
Error: "CSRF token validation error"
Possible Causes:
- SAP API requires CSRF tokens for POST/PUT requests
- SAP might be checking for specific headers
Solutions:
-
Get CSRF Token First:
- Make a GET request to the SAP service root to get CSRF token
- Example:
GET https://RENOIHND01.Eichergroup.com:1443/sap/opu/odata/sap/ZFI_BUDGET_BLOCK_API_SRV/ - Look for
x-csrf-tokenheader in response - Add this token to subsequent POST/PUT requests as header:
X-CSRF-Token: <token>
-
Add Required Headers:
X-CSRF-Token: Fetch X-Requested-With: XMLHttpRequest
2. Authentication Failed
Error: "Authentication failed" or "401 Unauthorized"
Possible Causes:
- Wrong username/password
- Basic auth not being sent correctly
- SSL certificate issues
- SAP account locked or expired
Solutions:
-
Verify Credentials:
- Double-check
SAP_USERNAMEandSAP_PASSWORDin.env - Ensure no extra spaces or special characters
- Test credentials in browser first
- Double-check
-
Check SSL Certificate:
- If using self-signed certificate, set
SAP_DISABLE_SSL_VERIFY=truein.env(testing only!) - For production, ensure proper SSL certificates are configured
- If using self-signed certificate, set
-
Test Basic Auth Manually:
- Use Postman with Basic Auth enabled
- Verify the Authorization header format:
Basic <base64(username:password)>
-
Check SAP Account Status:
- Verify account is active and not locked
- Check if password has expired
- Contact SAP administrator if needed
3. Connection Errors
Error: "ECONNREFUSED" or "ENOTFOUND"
Solutions:
- Verify
SAP_BASE_URLis correct - Check network connectivity to SAP server
- Ensure firewall allows connections to port 1443
- Verify Zscaler is configured correctly
4. Timeout Errors
Error: "Request timeout"
Solutions:
- Increase
SAP_TIMEOUT_MSin.env(default: 30000ms = 30 seconds) - Check SAP server response time
- Verify network latency
Debugging
Enable Debug Logging
Set log level to debug in your .env:
LOG_LEVEL=debug
This will log:
- Request URLs
- Request payloads
- Response status codes
- Response data
- Error details
Check Backend Logs
Look for [SAP] prefixed log messages:
# In development
npm run dev
# Check logs for SAP-related messages
Test SAP Connection
You can test if SAP is reachable:
curl -u "username:password" \
"https://RENOIHND01.Eichergroup.com:1443/sap/opu/odata/sap/ZFI_BUDGET_CHECK_API_SRV/"
Environment Variables Checklist
Ensure these are set in your .env:
# Required
SAP_BASE_URL=https://RENOIHND01.Eichergroup.com:1443
SAP_USERNAME=your_username
SAP_PASSWORD=your_password
# Optional (with defaults)
SAP_TIMEOUT_MS=30000
SAP_SERVICE_NAME=ZFI_BUDGET_CHECK_API_SRV
SAP_BLOCK_SERVICE_NAME=ZFI_BUDGET_BLOCK_API_SRV
SAP_REQUESTER=REFMS
SAP_DISABLE_SSL_VERIFY=false # Only for testing
Next Steps
If you're still getting errors:
- Check Backend Logs: Look for detailed error messages
- Test Directly in Postman: Bypass backend and test SAP API directly
- Verify SAP Credentials: Test with SAP administrator
- Check Network: Ensure server can reach SAP URL
- Review SAP Documentation: Check if there are additional requirements