Restsharp: كيفية: إرسال HTTP Post لكائن معقد باستخدام RestSharp

تم إنشاؤها على ٤ أكتوبر ٢٠١٣  ·  3تعليقات  ·  مصدر: restsharp/RestSharp

هل يمكن لشخص ما أن ينصحك بكيفية إرسال منشور HTTP مع ما يلي كمعلمات الطلب.

{
    "key": "example key",
    "message": {
        "html": "<p>Example HTML content</p>",
        "text": "Example text content",
        "subject": "example subject",
        "from_email": "[email protected]",
        "from_name": "Example Name",
        "to": [
            {
                "email": "[email protected]",
                "name": "Recipient Name"
            }
        ],
        "headers": {
            "Reply-To": "[email protected]"
        },
        "important": false,
        "track_opens": null,
        "track_clicks": null,
        "auto_text": null,
        "auto_html": null,
        "inline_css": null,
        "url_strip_qs": null,
        "preserve_recipients": null,
        "view_content_link": null,
        "bcc_address": "[email protected]",
        "tracking_domain": null,
        "signing_domain": null,
        "return_path_domain": null,
        "merge": true,
        "global_merge_vars": [
            {
                "name": "merge1",
                "content": "merge1 content"
            }
        ],
        "merge_vars": [
            {
                "rcpt": "[email protected]",
                "vars": [
                    {
                        "name": "merge2",
                        "content": "merge2 content"
                    }
                ]
            }
        ],
        "tags": [
            "password-resets"
        ],
        "subaccount": "customer-123",
        "google_analytics_domains": [
            "example.com"
        ],
        "google_analytics_campaign": "[email protected]",
        "metadata": {
            "website": "www.example.com"
        },
        "recipient_metadata": [
            {
                "rcpt": "[email protected]",
                "values": {
                    "user_id": 123456
                }
            }
        ],
        "attachments": [
            {
                "type": "text/plain",
                "name": "myfile.txt",
                "content": "ZXhhbXBsZSBmaWxl"
            }
        ],
        "images": [
            {
                "type": "image/png",
                "name": "IMAGECID",
                "content": "ZXhhbXBsZSBmaWxl"
            }
        ]
    },
    "async": false,
    "ip_pool": "Main Pool",
    "send_at": "example send_at"
}

لست متأكدًا من كيفية القيام بذلك باستخدام RestSharp

التعليق الأكثر فائدة

أهلا،

1) ترجمة JSON إلى POCO (http://json2csharp.com/ رائع لذلك).
2)
var yourobject = new MyObject {.....................} ؛
var json = JsonConvert.SerializeObject (yourobject) ،

var client = جديد RestClient (url) ؛

طلب var = RestRequest جديد (actionPath، Method.POST) ؛
request .AddParameter ("application / json؛ charset = utf-8"، json، ParameterType.RequestBody)؛
request .RequestFormat = DataFormat.Json ،

_client.ExecuteAsync (restRequest، response => ........) ؛

ال 3 كومينتر

أهلا،

1) ترجمة JSON إلى POCO (http://json2csharp.com/ رائع لذلك).
2)
var yourobject = new MyObject {.....................} ؛
var json = JsonConvert.SerializeObject (yourobject) ،

var client = جديد RestClient (url) ؛

طلب var = RestRequest جديد (actionPath، Method.POST) ؛
request .AddParameter ("application / json؛ charset = utf-8"، json، ParameterType.RequestBody)؛
request .RequestFormat = DataFormat.Json ،

_client.ExecuteAsync (restRequest، response => ........) ؛

tks لي أيضا!

للأجيال القادمة RestSharp لديها أساليب يحمل في ثناياه عوامل لهذا الآن.
تحقق من طريقة AddJsonBody() لـ RestRequest
هذا صحيح لـ RestSharp 105.0.1.0 وما بعده على أية حال.

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات

القضايا ذات الصلة

captnrob picture captnrob  ·  3تعليقات

vDeggial picture vDeggial  ·  6تعليقات

qJake picture qJake  ·  7تعليقات

weswitt picture weswitt  ·  3تعليقات

AlexanderSchoenfeld picture AlexanderSchoenfeld  ·  3تعليقات