How AmazonAdsAPI Handles Content for Media Type appapplication/vnd.spCampaign.v3+json 」

Asked 1 years ago, Updated 1 years ago, 432 views

How can I pass the content of the media type "application/vnd.spCampaign.v3+json" from AmazonAdsAPI in C#?

I am currently trying to run ADSAPI sp/campaigns/list in post in HttpClient in C#.
You need to pass the content by media type "application/vnd.spCampaign.v3+json".
However, I do not know how to create content in this format.

Could you tell me how to pass content to this media type?

Make your first call to the Amazon Ads API
https://advertising.amazon.com/API/docs/en-us/getting-started/first-call#/sample-requests

c# http

2023-02-20 03:08

1 Answers

I have solved myself.
Create a StringContent in json format as you did with media type
application/json. Resolved by changing media type to application/vnd.spCampaign.v3+json

public static async Task<StringContent>GetContentFormJson(object data,Encoding encode=null,Encoding contentEncoding=null)
{
    try
    {
        var json=data converted to json
        if(json!=null)
        {
            var content = new StringContent(json, contentEncoding??) Encoding.UTF8, @"application/json";
            content.Headers.ContentType=new MediaTypeHeaderValue("application/vnd.spCampaign.v3+json");
            return content;
        }
    }
    catch (Exception ex)
    {
        error log handling
    }
    return null;
}


2023-02-20 05:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.