แชร์ผ่าน


เรียกใช้รายการของกฎ

กฎถูกจัดกลุ่มเข้าด้วยกันโดยใช้ชุดกฎ กฎไม่สามารถอยู่ในชุดกฎหรือชุดกฎหลายชุด ใช้คำขอ GET เพื่อรับรายการของกฎทั้งหมดที่มีอยู่ กฎในชุดกฎ หรือชุดกฎ โดยการเรียก API [Geographical URI]/api/rule มีความแตกต่างเล็กน้อยในการเรียกใช้ API นี้ อย่างไรก็ตาม การใช้งานที่พบบ่อยที่สุดคือ การเรียกดูรายการกฎสำหรับชุดกฎเฉพาะ

หมายเหตุ

API นี้ต้องการโทเค็น OAuth

ส่วนหัว

Name ชนิด ค่าที่คาดหวัง จำเป็นหรือไม่
ยอมรับ-ภาษา สตริง รหัสภาษา (เช่น en-US) ค่าเริ่มต้น คือ en-US ไม่

พารามิเตอร์

ชื่อ ชนิด ค่าที่คาดหวัง จำเป็นหรือไม่
ชุดกฎ สตริง ชื่อหรือรหัสของชุดกฎ หรือรายการของรหัสชุกกฎ หรือชื่อที่คั่นด้วยเครื่องหมายจุลภาคหรืออัฒภาค (เช่น "ตัวตรวจสอบโซลูชัน") ไม่
includeMessageFormats บูลีน เมื่อตั้งค่าเป็น true รายการรูปแบบข้อความที่เป็นไปได้จะรวมอยู่ในผลลัพธ์ของคำขอภาษา หากมี รายการนี้มีประโยชน์สำหรับการแปลเป็นหลายภาษา หากไม่ต้องการ ให้ระบุพารามิเตอร์นี้หรือระบุ false เป็นค่าที่เป็นพารามิเตอร์ ซึ่งเพิ่มขนาดของการตอบสนอง และสามารถเพิ่มเวลาการประมวลผล ไม่

คำตอบที่คาดหวัง

รหัสสถานะ HTTP สถานการณ์สมมติ ผลลัพธ์
200 พบผลลัพธ์หนึ่งรายการขึ้นไป ดูตัวอย่างภายหลังในบทความนี้ อาจส่งคืนผลลัพธ์อย่างน้อยหนึ่งรายการ
204 ไม่พบผลลัพธ์ ไม่มีผลลัพธ์ในเนื้อหาการตอบกลับ
401 การรับรองความถูกต้องล้มเหลว ไม่มีผลลัพธ์ในเนื้อหาการตอบกลับ

เนื้อหาคำตอบที่คาดหวัง

ตารางต่อไปนี้แสดงโครงสร้างของการตอบสนองสำหรับแต่ละคำขอ (การตอบสนอง HTTP 200 เท่านั้น)

คุณสมบัติ ชนิด ค่าที่คาดหวัง จำเป็นหรือไม่
รหัส สตริง ตัวระบุของกฎบางครั้งเรียกว่า รหัสกฎ ใช่
สรุป สตริง สรุปของกฎ ใช่
คำอธิบาย สตริง คำอธิบายรายละเอียดเพิ่มเติมของกฎ ใช่
guidanceUrl URI URL สำหรับค้นหาคำแนะนำที่เผยแพร่ อาจมีบางกรณีที่ไม่มีบทความแนะนำการสนับสนุนโดยเฉพาะ ใช่
รวม แบบบูลีน สัญญาณไปยังบริการจะรวมกฎในการวิเคราะห์ ค่านี้คือ true สำหรับ API นี้ ไม่
messageTemplates อาร์เรย์ ค่าคุณสมบัตินี้จะรวมเฉพาะเมื่อ includeMessageFormats คือ true ไม่
messageTemplates.ruleId สตริง ส่งคืนค่ารหัสเดียวกันกับคุณสมบัติ code ใช่
messageTemplates.messageTemplateId string ตัวระบุที่ใช้ในรายงาน Static Analysis Results Interchange Format (SARIF) เพื่อส่งสัญญาณการเปลี่ยนแปลงข้อความปัญหาสำหรับกฎ ใช่
messageTemplates.messageTemplate สตริง ข้อความของรูปแบบข้อความสำหรับสถานการณ์ปัญหาที่กฎรายงาน ข้อความนี้คือสตริงรูปแบบที่อาจมีโทเค็นซึ่งข้อโต้แย้งที่ระบุไว้ในรายงาน SARIF สามารถใช้เพื่อสร้างข้อความโดยละเอียดได้ ใช่

ตัวอย่าง: ดึงกฎสำหรับชุดกฎในภาษาอื่น

ตัวอย่างนี้ส่งคืนข้อมูลสำหรับกฎทั้งหมดในชุดกฎ ตัวตรวจสอบโซลูชัน ในภาษาฝรั่งเศส หากภาษาที่ต้องการเป็นภาษาอังกฤษ ให้ลบส่วนหัว ยอมรับภาษา

คำขอ

GET [Geographical URI]/api/rule?ruleset=083A2EF5-7E0E-4754-9D88-9455142DC08B&api-version=2.0
x-ms-correlation-id: 9E378E56-6F35-41E9-BF8B-C0CC88E2B832
Accept: application/json
Content-Type: application/json; charset=utf-8
Accept-Language: fr

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
    {
        "description": "Ne pas implémenter d’activités de workflow Microsoft Dynamics CRM 4.0",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=il-avoid-crm4-wf&client=PAChecker",
        "include": true,
        "code": "il-avoid-crm4-wf",
        "summary": "Ne pas implémenter d’activités de workflow Microsoft Dynamics CRM 4.0",
        "howToFix": {
            "summary": ""
        }
    },
    {
        "description": "Utiliser InvalidPluginExecutionException dans des plug-ins et activités de workflow",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=il-use-standard-exception&client=PAChecker",
        "include": true,
        "code": "il-use-standard-exception",
        "summary": "Utiliser InvalidPluginExecutionException dans des plug-ins et activités de workflow",
        "howToFix": {
            "summary": ""
        }
    },
...
]

ตัวอย่าง: ดึงทั้งหมด

ตัวอย่างนี้ส่งคืนข้อมูลสำหรับกฎทั้งหมดที่มี

คำขอ

GET [Geographical URI]/api/rule?api-version=2.0
Accept: application/json
Content-Type: application/json; charset=utf-8

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
    {
        "description": "Retrieve specific columns for an entity via query APIs",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=il-specify-column&client=PAChecker",
        "include": true,
        "code": "il-specify-column",
        "summary": "Retrieve specific columns for an entity via query APIs",
        "howToFix": {
            "summary": ""
        }
    },
    {
        "description": "Do not duplicate plug-in step registration",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=meta-remove-dup-reg&client=PAChecker",
        "include": true,
        "code": "meta-remove-dup-reg",
        "summary": "Do not duplicate plug-in step registration",
        "howToFix": {
            "summary": ""
        }
    },
...
]

ตัวอย่าง: ดึงข้อมูลสำหรับชุดกฎที่มีรูปแบบข้อความ

ตัวอย่างนี้ส่งคืนข้อมูลสำหรับกฎทั้งหมดในชุดกฎ ตัวตรวจสอบโซลูชัน ในภาษาฝรั่งเศส หากภาษาที่ต้องการเป็นภาษาอังกฤษ ให้ลบส่วนหัว ยอมรับภาษา

คำขอ

GET [Geographical URI]/api/rule?ruleset=083A2EF5-7E0E-4754-9D88-9455142DC08B&includeMessageFormats=true&api-version=2.0
Accept: application/json
Content-Type: application/json; charset=utf-8

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

[
    {
        "description": "Do not implement Microsoft Dynamics CRM 4.0 workflow activities",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=il-avoid-crm4-wf&client=PAChecker",
        "include": true,
        "code": "il-avoid-crm4-wf",
        "summary": "Do not implement Microsoft Dynamics CRM 4.0 workflow activities",
        "howToFix": {
            "summary": ""
        },
        "messageTemplates": [
            {
                "ruleId": "il-avoid-crm4-wf",
                "messageTemplateId": "message1",
                "messageTemplate": "Update the {0} class to derive from System.Workflow.Activities.CodeActivity, refactor Execute method implementation, and remove Microsoft.Crm.Workflow.CrmWorkflowActivityAttribute from type"
            },
            {
                "ruleId": "il-avoid-crm4-wf",
                "messageTemplateId": "message2",
                "messageTemplate": "Change the {0} property's type from {1} to {2} Argument <T> type"
            },
            {
                "ruleId": "il-avoid-crm4-wf",
                "messageTemplateId": "message3",
                "messageTemplate": "Replace the Microsoft.Crm.Workflow.Crm{0}Attribute with Microsoft.Xrm.Sdk.Workflow.{0}Attribute"
            },
            {
                "ruleId": "il-avoid-crm4-wf",
                "messageTemplateId": "message4",
                "messageTemplate": "Remove the {0} System.Workflow.ComponentModel.DependencyProperty type field"
            }
        ]
    },
    {
        "description": "Use InvalidPluginExecutionException in plug-ins and workflow activities",
        "guidanceUrl": "https://go.microsoft.com/fwlink/?LinkID=398563&error=il-use-standard-exception&client=PAChecker",
        "include": true,
        "code": "il-use-standard-exception",
        "summary": "Use InvalidPluginExecutionException in plug-ins and workflow activities",
        "howToFix": {
            "summary": ""
        },
        "messageTemplates": [
            {
                "ruleId": "il-use-standard-exception",
                "messageTemplateId": "message1",
                "messageTemplate": "An unguarded throw of type {0} was detected. Refactor this code to either throw an exception of type InvalidPluginExecutionException or guard against thrown exceptions of other types."
            },
            {
                "ruleId": "il-use-standard-exception",
                "messageTemplateId": "message2",
                "messageTemplate": "An unguarded rethrow of type {0} was detected. Refactor this code to either throw an exception of type InvalidPluginExecutionException or guard against thrown exceptions of other types."
            }
        ]
    },
...
]

ดูเพิ่มเติม

ใช้ API เว็บของตัวตรวจสอบ Power Apps
เรียกใช้ชุดรายการของข้อกำหนด
อัปโหลดแฟ้ม
เรียกใช้การวิเคราะห์
ตรวจสอบสถานะการวิเคราะห์