如何解决此问题?{" messageCode":" 1000"," Message":" Value not not null.\\\ \\\ 参数名称:g"}。 [英] How to solve this problem?{"messageCode":"1000","Message":"Value cannot be null.\u000d\u000a Parameter name: g"}.

查看:111
本文介绍了如何解决此问题?{" messageCode":" 1000"," Message":" Value not not null.\\\ \\\ 参数名称:g"}。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

static void Main(string[] args)
        {
 string consumerKey = "xxxxxxxx"; // Received From Martjack
            string secretKey = "xxxxxxxxxxxxxxxxxxxxxxxx"; // Received From Martjack  

            string url = "http://www.martjack.com/DeveloperAPI//Product/UpdateProductInfo";
 string jsonString='{"products":{"product":{"sku":"6BATINSP15R","varientsku":"0","MRP":"91039","webprice":"91039","inventory":"100.0000"}}}';
 string response = PostRequest(url, consumerKey, secretKey, jsonString); // Function Call}

   public static string PostRequest(string url, string consumerKey, string secretKey, string jsonString, string outputFormat = "application/json")
        {
            try
            {
                OAuth.OAuthBase authBase = new OAuth.OAuthBase();
                Uri uri = new Uri(url);

                string method = "POST";
                string timeStamp = authBase.GenerateTimeStamp();
                string nounce = authBase.GenerateNonce();
                string normalizedUrl = string.Empty;
                string normalizedRequestParameters = string.Empty;

                string strSign = authBase.GenerateSignature(uri, consumerKey, secretKey, null, null, method, timeStamp, nounce, out normalizedUrl, out normalizedRequestParameters);

                var request = (HttpWebRequest)WebRequest.Create(url);
                request.ContentType = "application/x-www-form-urlencoded";
                request.Accept = outputFormat;
                request.Method = method;

                request.Headers.Add("oauth_consumer_key", consumerKey);
                request.Headers.Add("oauth_nonce", nounce);
                request.Headers.Add("oauth_signature", authBase.UrlEncode(strSign));
                request.Headers.Add("oauth_signature_method", "HMAC-SHA1");
                request.Headers.Add("oauth_timestamp", timeStamp);
                request.Headers.Add("oauth_version", "1.0");

                ASCIIEncoding encoding = new ASCIIEncoding();
                byte[] byteArray = encoding.GetBytes(jsonString);
                request.ContentLength = byteArray.Length;
                Stream dataStream = request.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();

                var response = request.GetResponse();
                var respString = new StreamReader(response.GetResponseStream()).ReadToEnd();

                return respString;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

推荐答案

建议

- 永远不要在发布给公众的代码中提供您的用户ID和密码。从来没有,无论如何。



如何解决错误:



由他人解决:

- 在代码中给出错误位置,以帮助帮助者找出问题所在。

- 一些句子解释代码的作用不会造成伤害。



自己解决:

- 学习使用调试器,以及错误信息和错误位置,你必须能够解决问题你自己。

- 错误信息告诉你出了什么问题。

自己解决问题会产生次要影响,它可以提高你的编程技巧。



错误发生在被调用函数中, g 是该函数的参数,没有原型就无法提供帮助。
Advice:
- Never ever give your user id and password in code posted to public. Never, no matter what.

How to solve the error:

To solve by others:
- Give error location in code in order to help helpers to figure where is the problem.
- A couple sentences explaining what is doing the code would not harm.

To solve it yourself:
- Learn to use the debugger, along with the error message and error location, you must be able to solve the problem yourself.
- The error message tells you what is wrong.
Solving the problem yourself have a secondary effect, it improve your programming skills.

The error occur in a called function and g is a parameter of that function, no help is possible without prototypes.


这篇关于如何解决此问题?{" messageCode":" 1000"," Message":" Value not not null.\\\ \\\ 参数名称:g"}。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆