Branch.io 在 c# 中使用 HTTP API 的链接

Branch.io Links using the HTTP API in c#

我试图在我们的网页中通过 HTTP API 调用创建 link,但是当我尝试创建 link 时。 HttpClient 响应始终为 false。我不确定为什么,但我指定了所有必要的参数

const string BranchIOUrl = "https://api.branch.io/v1/url";

            IDictionary<string, object> branchParams = new Dictionary<string, object>();
            IDictionary<string, string> dataParams = new Dictionary<string, string>();

            branchParams["$branch_key"] = "our branch key";
            branchParams["channel"] = "mobile_web";
            branchParams["feature"] = "create_link";                

            dataParams["$ios_deeplink_path"] = "value here";                                        
            dataParams["$user_profile"] = "7890";
            dataParams["$desktop_url"] = "our app link on appstore";

            branchParams["data"] = dataParams;

            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(BranchIOUrl);

            //Add an accept header for JSon format.
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            // List data response.
            HttpResponseMessage response = await client.PostAsJsonAsync(BranchIOUrl, Newtonsoft.Json.JsonConvert.SerializeObject(branchParams));

来自 Branch.io 的亚历克斯:

看来问题出在这一行:

branchParams["$branch_key"] = "our branch key";

branch_key 参数实际上是在 没有 $ 字符的情况下指定的(我知道,它属于哪里有点令人困惑)。如果将其替换为:

branchParams["branch_key"] = "our branch key";

你应该可以开始了!