Skip to content

Latest commit

 

History

History
214 lines (163 loc) · 5.83 KB

File metadata and controls

214 lines (163 loc) · 5.83 KB

WeGenius API Testing Results

Date: October 10, 2025
Endpoint Tested: POST /api/ai/articles/submit
Status:WORKING


Test Summary

Successfully tested the article submission endpoint with cURL and verified the API is working correctly on production.

✅ Successful Test Request

curl -X POST "https://wegenius.fahmidsroadmap.com/api/ai/articles/submit" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: wg_XIQRl6d1wzZvODpgpc8zaDeR4hTxpWOk" \
  -H "Accept: application/json" \
  -d '{
  "wp_post_id": 999,
  "title": "Test Article from cURL - API Verification",
  "content": "This is a test article...",
  "permalink": "https://wegenius.test/test-article-from-curl-verification/",
  "featured_image": "https://wegenius.test/wp-content/uploads/test-image.jpg",
  "status": "published",
  "published_at": "2025-10-10 10:00:00",
  "author_name": "Test User",
  "action_type": "improve",
  "meta_data": {
    "categories": ["Testing"],
    "tags": ["curl", "api-test"],
    "excerpt": "Testing API endpoint"
  },
  "user_preferences": {
    "focus_on": "readability",
    "target_audience": "general",
    "content_length": "detailed"
  }
}'

✅ Successful Response

{
  "success": true,
  "message": "Article submitted for analysis",
  "data": {
    "analysis_id": 6,
    "post_id": 8,
    "wp_post_id": 999,
    "title": "Test Article from cURL - API Verification",
    "analysis_type": "improve",
    "status": "pending",
    "estimated_completion": "2025-10-10T06:15:12.844049Z"
  }
}

HTTP Status: 201 Created


Critical Fixes Applied

1. ⚠️ API Key Header Name (CASE-SENSITIVE)

  • WRONG: X-API-KEY (all uppercase)
  • CORRECT: X-API-Key (mixed case)
  • Middleware Location: app/Http/Middleware/ApiKeyAuthentication.php:19

2. ⚠️ Status Field Values

  • WRONG: "status": "publish"
  • CORRECT: "status": "published", "draft", or "pending"

3. ⚠️ Featured Image Field

  • WRONG: "featured_image": false
  • CORRECT: "featured_image": "https://example.com/image.jpg" or null
  • Must be: A valid URL string or null (NOT a boolean)

4. ✅ Action Type (Already Correct)

  • Valid Values: "improve", "content_gap", "new_article"
  • INVALID: "ideas" (this was found in some logs)

Postman Collection Updates

Updated Fields:

  1. Authentication Header:

    • Changed from X-API-KEY to X-API-Key
  2. Sample Request Body:

    • Changed featured_image: falsefeatured_image: "https://wegenius.test/wp-content/uploads/test-image.jpg"
    • Changed status: "publish"status: "published"
    • Updated to use better test data
  3. Collection Description:

    • Added important notes about field requirements
    • Added setup instructions
    • Highlighted common mistakes
  4. URL Structure:

    • Fixed all endpoints to include proper host and path arrays
    • Ensured Postman correctly resolves {{base_url}} variable

Production API Key

Current Production Key: wg_XIQRl6d1wzZvODpgpc8zaDeR4hTxpWOk

  • Site: Violet Huber
  • Status: Active ✅
  • Token Limit: 10,000
  • Tokens Used: Available

Note: This key is for testing only. Each WordPress site should have its own unique API key.


Files Updated

  1. WeGenius_WordPress_API.postman_collection.json

    • Fixed authentication header name
    • Updated sample request data
    • Added comprehensive documentation
  2. test-api-submit.sh

    • Updated with correct field values
    • Added usage notes
    • Fixed header name
  3. get-api-key.php

    • Created script to fetch API keys from database
    • Useful for testing and debugging

How to Use the Postman Collection

Step 1: Import Collection

  • Import WeGenius_WordPress_API.postman_collection.json into Postman

Step 2: Set Variables

  1. Click on the collection name
  2. Go to "Variables" tab
  3. Update api_key with your actual API key from:

Step 3: Test Endpoints

  • The collection automatically uses the X-API-Key header
  • Base URL is already set to production
  • All endpoints are ready to test

Step 4: Check Field Values

  • Ensure status is: published, draft, or pending
  • Ensure featured_image is a URL string or null
  • Ensure action_type is: improve, content_gap, or new_article

Common Errors and Solutions

Error: "Invalid API key"

Solution:

  • Check header name is X-API-Key (case-sensitive)
  • Verify API key is correct
  • Ensure WordPress site is active

Error: "The selected status is invalid"

Solution:

  • Change "status": "publish" to "status": "published"

Error: "The featured image field must be a valid URL"

Solution:

  • Change "featured_image": false to a valid URL or null
  • Example: "featured_image": "https://example.com/image.jpg"

Error: "Token limit exceeded"

Solution:

  • Check token usage in dashboard
  • Upgrade plan or wait for reset

Next Steps

  1. ✅ API endpoint verified and working
  2. ✅ Postman collection updated and uploaded
  3. ✅ Test script created and uploaded
  4. ⏳ Monitor cron job execution at: https://wegenius.fahmidsroadmap.com/cron-status.php
  5. ⏳ Test complete workflow: Submit → Process → Display Suggestions

Testing Checklist

  • API endpoint accessible
  • Authentication working with correct header
  • Article submission creates analysis record
  • Response includes analysis_id and estimated_completion
  • HTTP 201 status returned on success
  • Field validation working correctly
  • Cron job processes queued analysis
  • Suggestions generated and stored
  • Suggestions display correctly in dashboard
  • Suggestion implementation works

Test Conducted By: AI Assistant
Production URL: https://wegenius.fahmidsroadmap.com
Documentation: API_DOCUMENTATION.md