首页 > 解决方案 > 不支持的媒体文件类型

问题描述

在使用 fetch web api 进行发布请求并传递一些带有哈希和签名的 json 数据作为标头参数时,每次执行代码错误似乎是不受支持的文件类型,但与错误相反,我的标头和正文是正确的,另外我的正文参数也不是文件,所以我很困惑这里有什么问题。请调查一下。

fetch('https://sboxapi.lazypay.in/api/lazypay/v2/payment/eligibility',{
                     method: 'post',
                     body : occFormatResponse,
                     header  :{
                         'signature' : hash,
                         'accessKey' : merchantAccessKey,
                         'Content-Type': 'application/json',
                     }
                 })
                 .then(function(result){
                    console.log('result>>>>>>>',result);
                    // return result;
                 })
                 .catch(function(error){
                    console.log('error while  checking the eligibiliy>>>>>>',error);
                    // return error.response;
                 })

下面是错误

{"timestamp":1559713841465,"status":415,"error":"Unsupported Media Type","path":"/api/lazypay/v2/payment/eligibility","errorCode":"LP_GENERIC_ERROR","message":"Oops!! Something went wrong"}

机身参数

        {   
                "userDetails" : {
                    "firstname" : "ravi",
                    "lastname" : "singh",
                    "mobile" : "9892197128",
                    "email" : "ravi.singh@adapty.com"
                },
                "amount" : {
                    "value" : 1000,
                    "currency" : "INR"
                },
                "address" : {
                    "address1" : "street1",
                    "address2" : "street2",
                    "city" : "pune",
                    "state" : "MH",
                    "country" : "IN",
                    "zip" : "411045"
                },
                "productSkuDetails" : {
                    "productId" : "10537492PK",
                    "description" : "test product",
                    "attributes" : {
                        "size" : "S",
                        "color" : "blue"
                    },
                    "imageUrl" : "www.google.com",
                    "shippable" : true,
                    "skuId" : "10537492",
                    "price" : 1000

                },
                "source" :  "fabindia",
                "customParams": {
                     "previousTransactionCount": "10",
                     "onboardingdate": "20-05-2009",
                     "usersignupdetails": "Google",
                     "IPaddress": "10.10.10.10"
                }
        }

标签: javascriptnode.jsexpress

解决方案


推荐阅读