Highlighted
Trusted Contributor.
Trusted Contributor.
11108 views

415 (Unsupported Media Type)

Jump to solution

I'm running into a 415 error that doesn't quite make sense to me because the content type is defined. I've also run in Fiddler and the content type is the same. What is this request missing? 

LoadRunner code:

web_custom_request("sign", 
        "URL=", 
        "Method=PUT", 
        "Resource=0", 
        "RecContentType=application/json;charset=utf-8",    
        "Referer=", 
        "Snapshot=t162.inf", 
        "Mode=HTML", 
        "Body={\"SignatureItem\":\"SVA0800A\",\"DateItem\":\"SVA0800B\",\"DateValue\":\"2016-06-08T04:00:00.000Z\",\"Password\":\"Dss.1234\",\"Data\":{\"SectionS\":{\"SVA0100\":\"\",\"SVA0101\":\"\",\"SVA0102\":\"\",\"SVA0200\":\"\",\"SVA0201\":\"\",\"SVA0300\":\"\",\"SVA0400\":\"\",\"SVA0500\":\"\",\"SVA0600\":\"\",\"SVA0601\":\"\",\"SVA0700\":\"\",\"SVA0701\":\"\",\"SVA0702\":\"\",\"SVA0800A\":\"\",\"SVA0800B\":\"\",\"SVA0801A\":\"\",\"SVA0801B\":\"\",\"SVA0802A\":\"\",\"SVA0802B\":\"\",\"SVA0803A\":\"\""
        ",\"SVA0803B\":\"\"}}}", 
        EXTRARES, 
        "Url=Z", "Referer=", ENDITEM, 
        LAST);

Fiddler Created Code:

    web_custom_request(".sign", 
        "URL=", 
        "Method=PUT", 
        "Resource=0", 
        "RecContentType=application/json", 
        "Referer=", 
        "Snapshot=t1.inf", 
        "Mode=HTML", 
        "Body={\"SignatureItem\":\"SVA0800A\",\"DateItem\":\"SVA0800B\",\"DateValue\":\"2016-06-09T04:00:00.000Z\",\"Password\":\"Dss.1234\",\"Data\":{\"SectionS\":{\"SVA0100\":\"\",\"SVA0101\":\"\",\"SVA0102\":\"\",\"SVA0200\":\"\",\"SVA0201\":\"\",\"SVA0300\":\"\",\"SVA0400\":\"\",\"SVA0500\":\"\",\"SVA0600\":\"\",\"SVA0601\":\"\",\"SVA0700\":\"\",\"SVA0701\":\"\",\"SVA0702\":\"\",\"SVA0800A\":\"\",\"SVA0800B\":\"\",\"SVA0801A\":\"\",\"SVA0801B\":\"\",\"SVA0802A\":\"\",\"SVA0802B\":\"\",\"SVA0803A\":\"\""
        ",\"SVA0803B\":\"\"}}}", 
        LAST);

 

Fiddler RAW Output:

PUT url HTTP/1.0
Content-Type: application/json;charset=utf-8
Accept: application/json, text/plain, */*
Authorization: Bearer nRNE4fGrYUc_d4bjHdzD2EYfF7roqmi8uT8aW_npOk9kAh9ABTnfaPQsPPH0IlehyjLHdt14bbJq0vanbaLZCSdVLNsQlJPxmXO5uDTPYW8_Zm1wg_UNvzt-dS01KmZuAU1G2_RSHHpI3_-zrBqDf9YKYqk6BHR_5_Et2boTYXcI0vK39zdSle68VpCJ6vkNKLwgbX5c1B9pxIrPKI1dggG9wjF6JGDlYGuKUdlp8ovzm-crXEYW8g2TD56XGE2t
AccessToken: BeNGtJtYJqXHiYQxnlF5Csgo45n9qfXN145OV/VjfypnNbLOov4F7FJvy2ExAgEpypKmbesR3vz5Y+bg+/mMc6gfXLDsFf/EKebPk60HfZ1hS69rxSyuQXgX4b73qU98isEFXgqqrgFFtroSFBl1sn2qxfdHOG22QgzFARCPYfFNNQR9VYfYi7NEkvd31yedRiyEWbqmrq+9l6Qq1EI0d4SdjpVIuoyjQbwUy2Cc3VWJ4eYn9Sz3rlXCJkRMGpBcJyDwlALG6HYmKkRFIokk3RxE/ktgquDahKoDPrNiHrYWG893Q2AXqLJ4AqlMZlQVv0dVOOt1i7cekV/OHZkHMtV3NYqY71yJOZUNllAMAjuFijaKC2UxlISN9gQqZk/sb4qDdJ32QGqu5HcK7vHtvKBn512e+crkaBRJBfxgexiXPf+PlRqPHmia/56wfT9M125lNduFFyJJA4FNWtiTF5Oen/V9RbAwHIpqz5HDZG+CC6gc+Repv8++uhp5aDr+5x/+UT/iV0hkG+2YYC8UwIJ0PFsxtNXj2N7m4aUl4fw=
Referer:
Accept-Language: en-US
Proxy-Connection: Keep-Alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Pragma: no-cache
Content-Length: 414
DNT: 1
Host: 

{"SignatureItem":"SVA0800A","DateItem":"SVA0800B","DateValue":"2016-06-09T04:00:00.000Z","Password":"Dss.1234","Data":{"SectionS":{"SVA0100":"","SVA0101":"","SVA0102":"","SVA0200":"","SVA0201":"","SVA0300":"","SVA0400":"","SVA0500":"","SVA0600":"","SVA0601":"","SVA0700":"","SVA0701":"","SVA0702":"","SVA0800A":"","SVA0800B":"","SVA0801A":"","SVA0801B":"","SVA0802A":"","SVA0802B":"","SVA0803A":"","SVA0803B":""}}}

 

Any help is appreciated

0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: 415 (Unsupported Media Type)

Jump to solution

    

 

    web_add_header("AccessToken","{VSOAToken}");
    web_add_header("Authorization","{txtTokenType} {txtAccessToken}");
    web_add_header("Accept","application/json, text/plain, */*");
    web_add_header("Origin", "http://weburl.com");

    web_custom_request("sign_2",
        "URL=http://weburl.com/api/facility/assessment/104/section/sign", 
        "Method=PUT", 
        "Resource=0",        
        "RecContentType=application/json;charset=utf-8",
        "Referer=http://weburl.com/menu/history/resident//22/assessment/22/104//assessment/section/S", 
        "Snapshot=t242.inf", 
        "Mode=HTML",
        "EncType=application/json;charset=utf-8",         
        "Body={\"SignatureItem\":\"SVA0800A\",\"DateItem\":\"SVA0800B\",\"DateValue\":\"2016-06-23T08:00:00.000Z\",\"Password\":\"Dss.1234\",\"Data\":{\"SectionS\":{\"SVA0100\":\"\",\"SVA0101\":\"\",\"SVA0102\":\"\",\"SVA0200\":\"\",\"SVA0201\":\"\",\"SVA0300\":\"\",\"SVA0400\":\"\",\"SVA0500\":\"\",\"SVA0600\":\"\",\"SVA0601\":\"\",\"SVA0700\":\"\",\"SVA0701\":\"\",\"SVA0702\":\"\",\"SVA0800A\":\"\",\"SVA0800B\":\"\",\"SVA0801A\":\"\",\"SVA0801B\":\"\",\"SVA0802A\":\"\",\"SVA0802B\":\"\",\"SVA0803A\":\"\""
        ",\"SVA0803B\":\"\"}}}", 
        LAST);

View solution in original post

0 Likes
3 Replies
Highlighted
Honored Contributor.
Honored Contributor.

Re: 415 (Unsupported Media Type)

Jump to solution

Hi,

 

There are many URL not authorized in the attachment provided. From the beginning of the script, it is showing " 401 Unauthorized" . Please check whether request with 401 are valid or not. 

If the script is valid, please convert the script with Data Format Extension(Json to XML) and regenerate it. Check whether you are getting the same error or not.

Regards,

Raghul M

 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: 415 (Unsupported Media Type)

Jump to solution

The 401's were not valid but have been handled. This seems to be a scripting issue with the request.

This is the request when performing the steps manually:

PUT https://dssinc.com/api/facility/assessment/827/section/sign HTTP/1.1

Content-Type: application/json;charset=utf-8

Accept: application/json, text/plain, */*

Authorization: Bearer DvyXfy_p6m3I9Rw015GxTyIdnJ7jAnFA09CXgORvfaq1uRDxWFgaXmmFfp3cbGLaha2Y7OPNCm_c6bt15Y7R9tKtcaOn-BQhgQMBerJRLN_yaDSMTyt9dZfQpNobzT21FwJcF1Ca_D9Du3iOtf6imfmgyipMWw1R_-XH9XgAuiQISyEX4p8B7bmvo1Fy4rAh1e5WSuWpzvFWCYqjluMnMxKGCwS-1-PNkeq10sd0GE5DPx0HHD5BeJ-hLZao2_Vq

AccessToken: BeNGtJtYJqXHiYQxnlF5Csgo45n9qfXN145OV/VjfypnNbLOov4F7FJvy2ExAgEpypKmbesR3vz5Y+bg+/mMc6gfXLDsFf/EKebPk60HfZ1hS69rxSyuQXgX4b73qU98isEFXgqqrgFFtroSFBl1sn2qxfdHOG22QgzFARCPYfFNNQR9VYfYi7NEkvd31yedRiyEWbqmrq+9l6Qq1EI0d4SdjpVIuoyjQbwUy2Cc3VWJ4eYn9Sz3rlXCJkRMGpBcJyDwlALG6HYmKkRFIokk3RxE/ktgquDahKoDPrNiHrYWG893Q2AXqLJ4AqlMZlQVv0dVOOt1i7cekV/OHZkHMtV3NYqY71yJOZUNllAMAjuFijaKC2UxlISN9gQqZk/sb4qDdJ32QGqu5HcK7vHtvKBn512e+crkaBRJBfxgexhz1MBxzzfWzSGjJjuKF+Iaecn31d7gZivS7tYzVwptv/LEKGnRsiTlFYcuIX1p8zoeRF3wHFg1lItBHpdyLXuW+SgrQxUaud0GjXaMEobUhAK360g6/mOLXqa6M9dqn68=

Referer: http://dssinc.com/menu/history/resident//38/assessment/38/827//assessment/section/S

Accept-Language: en-US

Origin: http://dssinc.com

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko

Host: caribouapi.dssinc.com

Content-Length: 414

DNT: 1

Connection: Keep-Alive

Cache-Control: no-cache

 

 

This is request that LR sends (Note the missing fields):

PUT http://api.dssinc.com/api/facility/assessment/104/section/sign HTTP/1.0

Authorization: bearer Ou4P_Nz7_hDwzLWKsO0CtsCEpxgg3gJTAk1gYHJlejE8effdLkkCqRUyPF5mhz2E4kCIzU972b73o7e78iIdg1djjaCjbuHq_6ljfHETpWwsBVxHqSx19IGiAi9dyeqyaONYh92SqsW4OmtluL34xa5Ui3jD8vrGUgTNp6jtBSyg13ABdoqRFMTnqPPUamFAYVZ1EBvT7bS6RZYgzt_2slRMe1oq3dgSbtpRZUi0y_A0u6aBrO0l4iOOFhinnQXZ

Referer: http://dssinc.com/menu/history/resident//22/assessment/22/104//assessment/section/S

User-Agent: Mozilla/5.0 (Windows; Trident/7.0; rv:11.0; en-us) like Gecko

Proxy-Connection: Keep-Alive

Accept-Language: en-US

Accept: */*

Host: api.dssinc.com

Content-Length: 414

Pragma: no-cache

 

 

This LR Recording request:

 

     web_add_header("Authorization","{txtTokenType} {txtAccessToken}");

 

     web_custom_request("sign_2",

          "URL=http://api.dssinc.com/api/facility/assessment/104/section/sign",

           "Method=PUT",

           "Resource=0",       

           "RecContentType=application/json;charset=utf-8",

          "Referer=http://.dssinc.com/menu/history/resident//22/assessment/22/104//assessment/section/S",

           "Snapshot=t242.inf",

           "Mode=HTML",

"Body={\"SignatureItem\":\"SVA0800A\",\"DateItem\":\"SVA0800B\",\"DateValue\":\"2016-06-13T04:00:00.000Z\",\"Password\":\"Dss.1234\",\"Data\":{\"SectionS\":{\"SVA0100\":\"\",\"SVA0101\":\"\",\"SVA0102\":\"\",\"SVA0200\":\"\",\"SVA0201\":\"\",\"SVA0300\":\"\",\"SVA0400\":\"\",\"SVA0500\":\"\",\"SVA0600\":\"\",\"SVA0601\":\"\",\"SVA0700\":\"\",\"SVA0701\":\"\",\"SVA0702\":\"\",\"SVA0800A\":\"\",\"SVA0800B\":\"\",\"SVA0801A\":\"\",\"SVA0801B\":\"\",\"SVA0802A\":\"\",\"SVA0802B\":\"\",\"SVA0803A\":\"\""

           ",\"SVA0803B\":\"\"}}}",

           LAST);

So it appears that i need to add the missing fields in a format that LR will accept. I am currently passing the Authorization in the header. Not sure what to do with the Access Token. Can web_add_header contain the authorization and the Access Token? 

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: 415 (Unsupported Media Type)

Jump to solution

    

 

    web_add_header("AccessToken","{VSOAToken}");
    web_add_header("Authorization","{txtTokenType} {txtAccessToken}");
    web_add_header("Accept","application/json, text/plain, */*");
    web_add_header("Origin", "http://weburl.com");

    web_custom_request("sign_2",
        "URL=http://weburl.com/api/facility/assessment/104/section/sign", 
        "Method=PUT", 
        "Resource=0",        
        "RecContentType=application/json;charset=utf-8",
        "Referer=http://weburl.com/menu/history/resident//22/assessment/22/104//assessment/section/S", 
        "Snapshot=t242.inf", 
        "Mode=HTML",
        "EncType=application/json;charset=utf-8",         
        "Body={\"SignatureItem\":\"SVA0800A\",\"DateItem\":\"SVA0800B\",\"DateValue\":\"2016-06-23T08:00:00.000Z\",\"Password\":\"Dss.1234\",\"Data\":{\"SectionS\":{\"SVA0100\":\"\",\"SVA0101\":\"\",\"SVA0102\":\"\",\"SVA0200\":\"\",\"SVA0201\":\"\",\"SVA0300\":\"\",\"SVA0400\":\"\",\"SVA0500\":\"\",\"SVA0600\":\"\",\"SVA0601\":\"\",\"SVA0700\":\"\",\"SVA0701\":\"\",\"SVA0702\":\"\",\"SVA0800A\":\"\",\"SVA0800B\":\"\",\"SVA0801A\":\"\",\"SVA0801B\":\"\",\"SVA0802A\":\"\",\"SVA0802B\":\"\",\"SVA0803A\":\"\""
        ",\"SVA0803B\":\"\"}}}", 
        LAST);

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.