Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

API PATCH

MD2050
8 - Asteroid

Hello Everyone- 

We have been struggling with this issue for few hours now and would really appreciate if we could get some direction (i read all the blogs posted and reached up to this point) . What we are trying to do here is to update 3 field values using a PATCH process , below snippet shows the AWF. Instead of building a JSON string using the tool we built the TEST string inside the formula tool looks like below , we are trying to update 3 values - "Code", "ShortName" and "LongName". 

 

{"Culture":{"Code":"en-US","ShortName":"Eng(US)","LongName":"Eng(US)"}}

 

Field schema is correct as we extracted it from the input data (which is in JSON format which gets parsed using JSON parser.)

I have also pasted the "Download Tool" configuration screens below - we tried using Basic>>Output>>string , Basic>>Output>>Blob , we got following message

 

{"Message":"The request entity's media type 'application/x-www-form-urlencoded' is not supported for this resource."}

 

so we tried adding Name = Content-Type and Value = application/x-www-form-urlencoded or Name = Content-Type and Value = application/json.  

 

Upon using the Basic>>Output>>Blob and Name = Content-Type and Value = application/json we didn't see any error under download data but do see below which means the PATCH process didnt work. Any idea what we are missing here ? Is it the string schema which we are trying to push that is not excepted or something else ?

 

MD2050_5-1634757387353.png

 

 

HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Content-Length: 339
Expires: Wed, 20 Oct 2021 20:46:33 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Wed, 20 Oct 2021 20:46:33 GMT
Connection: close
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

MD2050_1-1634756518651.png

 

MD2050_2-1634756710178.png  

 

MD2050_3-1634756728868.png

 

MD2050_4-1634756753216.png

 

 

Thank you,

M

16 REPLIES 16
MD2050
8 - Asteroid

Sure, Np-

Added the snippet below. 

I think i made some progress , i built the JSON using the tool instead of pasting it as a Sting - subsequent snippet shows AWF. I am getting below message now - notice i am getting a valid 200 OK and it says Connection- Alive which i was not getting in the prior messages... although even after getting a 200 OK my data is not getting patched. Is there anything you could suggest that i might be missing ? Thank you very much. 

 

HTTP/1.1 401 Unauthorized
Content-Length: 0
WWW-Authenticate: Basic
Access-Control-Allow-Credentials: true
Expires: Thu, 21 Oct 2021 17:22:50 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 21 Oct 2021 17:22:50 GMT
Connection: close
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

 

HTTP/1.1 200 OK
Content-Length: 0
Access-Control-Allow-Credentials: true
Expires: Thu, 21 Oct 2021 17:23:00 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 21 Oct 2021 17:23:00 GMT
Connection: keep-alive
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

 

 

 

MD2050_0-1634837498284.png



MD2050_1-1634837597847.png

 

 

 

BrandonB
Alteryx
Alteryx

I'm pretty sure that this API is expecting Basic authentication which is a Base64 encoded username:password string with the word Basic in front of it passed in as a value for an Authorization header. I could be wrong here, but if this is the case the issue is that it needs to be passed in as shown below rather than in the connection tab: 

 

BrandonB_0-1634837991185.png

 

 

 

MD2050
8 - Asteroid

Thank you @BrandonB - 

You are correct the Authentication is Basic which is in the message i am getting below. I also got a copy of API documentation which is not super helpful although the specific syntax for the patch along with an example is pasted below. Thank you very much. 

 

HTTP/1.1 401 Unauthorized
Content-Length: 0
WWW-Authenticate: Basic
Access-Control-Allow-Credentials: true
Expires: Thu, 21 Oct 2021 17:40:06 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 21 Oct 2021 17:40:06 GMT
Connection: keep-alive
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

 


HTTP/1.1 200 OK
Content-Type: application/json
Access-Control-Allow-Credentials: true
Vary: Accept-Encoding
Content-Encoding: gzip
Expires: Thu, 21 Oct 2021 17:40:07 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 21 Oct 2021 17:40:07 GMT
Content-Length: 554
Connection: keep-alive
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

 

MD2050_1-1634838584132.png

 

 

BrandonB
Alteryx
Alteryx

Perfect, so rather than entering your credentials in the connection tab, can you instead create a value using the formula tool that is your username:password. Then, use a Base64 Encoder tool to turn this string into a base 64 encoded string. Then use another formula tool to make a field called Authorization that says "Basic asld;hfasdifo" where the characters are the base 64 encoded string from the step prior. Then in your download tool that will come after this, please check the box in the headers tab for the Authorization field. This will pull the base 64 encoded Authorization string in as a header which will successfully authenticate against the API. It should look almost identical to my workflow example above. 

MD2050
8 - Asteroid

Thank you @BrandonB -

I followed your steps and now I am getting a HTTP 200 - OK 🙂 , unfortunately the data is still not getting PATCHED in the back-end. Thank you very much. 

 

MD2050_0-1634847266737.png

 

 

HTTP/1.1 200 OK
Content-Length: 0
Access-Control-Allow-Credentials: true
Expires: Thu, 21 Oct 2021 20:10:30 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 21 Oct 2021 20:10:30 GMT
Connection: keep-alive
Strict-Transport-Security: max-age=15768000 ; includeSubDomains

BrandonB
Alteryx
Alteryx

Excellent, well that resolves what was probably the main issue. Now the reason that it isn't being patched in the back end is likely due to the JSON format and/or additional headers or parameters that need to be passed. I'm not as familiar with the PATCH function other than instead of PUT it works more like an update. Maybe try the similar troubleshooting steps you took previously with different ways of entering the JSON as a first step. If you put it manually hard coded in first that is generally your best bet because then you can test out all of the other things with that the same. Without the API documentation it is tough to give any other recommendations, but I can say that with your authentication taken care of now you are in a much better spot because there is no chance data would update if it wasn't properly authenticating. 

MD2050
8 - Asteroid

Thank you @BrandonB and @apathetichell -

 

I was actually able to update one of the field which was not a part of parent-child hierarchy. 

 

Thank you very much for helping me on this, really appreciate your feedback. 

 

M.

Labels