dongningwen1146 2019-04-26 23:31
浏览 230

REST(PHP,CURL)PUT / POST XML问题:400错误请求,“无效URL”响应与Walmart OAuth API(邮递员测试)

There's a lot to unpack here. First of all, I've edited the title because I realize while eventually my REST request will be implemented into PHP code, right now I've stripped this down to Postman to test JUST the REST, so I've stripped it as low and basic as possible. I can officially say the problem is with my request.

Basically, I'm making a POST request and also testing with a PUT request to Walmart's API using the "new" OAuth authentication. Sounds grand. GET works BEAUTIFULLY in Postman and in my actual PHP code. POST and PUT immediately return the exact same error, no matter what and how I do: 400 Bad Request, Invalid URL. In the case of my PUT test, which I was doing because it's a simpler and faster text with far less XML to try to comb through, here's the exact response in HTML headers:

        <TITLE>Invalid URL</TITLE>
        <H1>Invalid URL</H1>
The requested URL "http&#58;&#47;&#47;&#37;5bNo&#37;20Host&#37;5d&#47;v3&#47;inventory&#63;", is invalid.


I have left testing in PHP through my server and moved into Postman to try to locate the exact issue I'm having, and GET requests work beautifully. I am generating a new Token every 15 minutes or so. I have done... SO many minor changes, but the way the Feed examples and requests work, for all that I can tell I'm doing everything right. I honestly think I'm losing my marbles at this point.

What is most frustrating to me is that GET works. My TOKEN is working. My OAuth is working just fine. A lot of the headers that GET uses for the Walmart API are the exact same between PUT/POST/GET. The difference here is ONLY that the link has query parameters AND XML being shoved into the body. Edit: What I mean is that my headers do not change between the GET and the POST; the only thing that changes in what I am supplying is that XML is being sent in the body, and that query params are required. This is the only thing that changes between a successful GET and an unsuccessful 400 bad request PUT/POST. This leads me to believe something is wrong with how I'm processing the query params or my XML, but considering in the below example I've copy/pasted the XML... I'm not sure. It is an existing item in our catalog, I know for a fact.

Something I have noticed that I'm not quite knowledgeable enough to know if it's an issue or not with Postman is that Walmart's API requests that content-type be multipart/form-data. I've noticed it uses the term "example" when stating this, however, it usually says "this or this" if it'll accept something else. If I switch content-type in Postman to multipart/form-data, however, the Body automatically becomes raw: text instead of raw: XML(application/xml) or text/xml. If I try to swap the raw to those types, it flips my content-type automatically to application/xml, so that's a little... hinky.

I am not going through a Proxy. I've turned off Global Proxy Configuration and Use System Proxy. Request timeout is set to 0. There's nothing Client Certificates. I mean, GET works, and my Token is successfully generated via outside PHP code (not in Postman, couldn't get that to work, said heck it).




Bearer Token: Bearer Basic --insert token here--

WM_SVC.NAME: Walmart Marketplace
WM_QOS.CORRELATION_ID: randomString123
WM_SEC.ACCESS_TOKEN: --insert token here--
Accept: application/xml
Content-type: multipart/form-data

BODY raw: XML(application/xml)

<?xml version="1.0" encoding="UTF-8"?>
<inventory xmlns="">

Exact response

400 Bad Request

        <TITLE>Invalid URL</TITLE>
        <H1>Invalid URL</H1>
The requested URL "http&#58;&#47;&#47;&#37;5bNo&#37;20Host&#37;5d&#47;v3&#47;inventory&#63;", is invalid.


Please send help, I think I've been staring at this so long I'm going to leave this physical world behind. Walmart relatively recently updated their authentication to OAuth and they've made vague passes at saying their old authentication will be deprecated and phased out, so I obviously want to try to get this to work.I tried to copy paste everything as best as possible. That XML is copy-pasted almost letter for letter from their example, with my own product switched in.

Also, the reference number down there always changes every time I run this, so it's not something I can actually look up. I've only supplied the Postman side of things because frankly if I can get that to work, my PHP will be fine, I've already knocked out some minor issues with the successful GET request.

If it's a semi-colon issue, I'll scream.

API Documentation:

  • 写回答

1条回答 默认 最新

  • drozwmi5440 2019-04-29 06:00

    Well, I've figured it out.

    You'll notice I'm required to supply a "Host" with my headers. That host is replacing my URl that I'm trying to connect to via POST/PUT/GET, so if my Host is, then my request URL is https://

    Once I took the https:// out of the host, the entire thing granted me a 200 response. The times I got a correct GET response, I had actually copy-pasted the correct HOST without the HTTPS by pure chance, so I completely missed this between my two separate test cases.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥15 win11安卓子系统打开谷歌登录不了切使用浏览器显示处于离线状态
    • ¥15 三维直角坐标系下,给定一个平面内四个点坐标,如何将四个点逆时针排序
    • ¥15 UnityWebRequest访问内网地址502
    • ¥20 Python语言来实现牛顿法(Newton's Method)解决非线性(系统)方程的问题。
    • ¥15 matlab控制工业相机采集图像
    • ¥25 R里做折线图和柱状图
    • ¥20 使用kokkos移植项目,遇到问题
    • ¥15 求该问题的Matlab代码
    • ¥15 python下使用pdpbox为何提示has no attribute 'pdp_isolate'?
    • ¥15 求java web病房管理系统项目,用netbeans做的