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

标签 c# dotnet-httpclient branch.io

我试图通过我们网页中的 HTTP API 调用创建链接,但是当我尝试创建链接时。 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 的 Alex:

看起来问题出在这一行:

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

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

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

你应该可以开始了!

关于c# - 在 C# 中使用 HTTP API 的 Branch.io 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37353849/

相关文章:

c# - 反射和方法使用

asp.net-mvc - 为什么我的属性路由不起作用?

ios - Branch.io:如何在 iOS 中的实时和测试环境之间切换

c# - 在 C# : Remove Task. Wait() 中使用 Web 服务

c# - HttpClient Parallel Requests Timeout using Task.WhenAll 当一个请求超时

Cordova 集成了branch.io 以邀请应用程序

ios - Expo 和 Branch 的通用链接 : Entitlements Error

c# - 更新语句以跟踪数据库中的 SortOrder

c# - 是否可以在 Asp.net 中将 session 超时设置为 1 分钟?

c# - 尝试设置 CruiseControl.net 时出现 CS0006 错误