Nested dictionaries in POST / Debug messages

#1

When trying to use a POST (using Torben’s example as blueprint) with a nested dictionary in the body, I get the #VALUE error message. My assumption is that it might be due to the string based syntax of dicts and key/value pairs, but the error message does not give any clues here. Is there a way to get more detailed error messages?

#2

Hey Alexander,
Would you be able to send me an example of one of your POST formulas, so we can take a look?

#3

@alexander.forstbach thanks for your message.

  1. The post seems to be working improperly, either on our end (bug), the service (?) or in the syntax you used. Can you please share your expression? @Torben and I will make sure to check it.
  2. Regarding your suggestion, yes! We are releasing detailed error messages and alerts in the coming weeks.

Thanks for your suggestion.

#4

Yep
POST(“https://api.appnexus.com/auth",’{"Content-type”: “application/json; charset=UTF-8”}’,’{“auth”: {“username”: “markoviangbr”, “password”: “xxx”}}’,0)

#5

@alexander.forstbach, can you please try

POST("https://api.appnexus.com/auth",'{"Content-type": "application/json; charset=UTF-8"}','{"auth": {"username": "markoviangbr", "password": "xxx"}}',0)

I fear its a smart-quote issue. Macs (as I think you’re using) frequently replace regular quotes " and ’ with smart quotes (left-and right sided) ” or ’ or many other formats. Currently we only support the first type and your formula seems to be using a mix of them. You can follow this topic and future evolutions at About JSON.

#6

You are right, the formula I used indeed had a mix of different high-commas. Tried using the formula you pasted - still doesnt work i.e. gives me back #VALUE. I know the service works using the header and body as specified, as we use it in python scripts etc regularly. Not sure how to best investigate from that error message tho

#7

@alexander.forstbach can you please show me a copy of the Python script please?

Checking the documentation of AppNexus I can see that they’re passing the authentication info as a -d command on curl, which means the header should be "Content": "application/x-www-form-url-encoded". Yet you send "Content": "application/json".

#8

Sure. Just used the logic in the get_new_auth_token method in the client module.

#9

thanks for your patience @alexander.forstbach

I took some time testing multiple combinations, and there seems to be an issue parsing the JSON in the 3rd parameter. Changed topic to Bugs.

In more Detail:

I’ve tested, successively and successfully, the following 2 combinations.

  • =POST("https://api.appnexus.com/auth",'{}','{}',0)
  • =POST("https://api.appnexus.com/auth",'{"Content-type":"application/json; charset=UTF-8"}','{}',0)

Which both return errors from the service. Then I tried the next step which failed:

  • =POST("https://api.appnexus.com/auth",'{"Content-type":"application/json; charset=UTF-8"}','{"auth": { "username": "markoviangbr","password": "xxx"}}',0)

Then I took a step back to a version that works:

  • =POST("https://api.appnexus.com/auth",'{"Content-type":"application/json; charset=UTF-8"}','{"auth": "username"}',0)

It’s weird the following also works

  • =PARSE('{"auth": { "username": "markoviangbr","password": "xxx"}}', "auth")

This will be reviewed shortly and I’ll get back to you asap.

#10

Hello @alexander.forstbach,

The POST() bug is now fixed.

Do you want to try now and let me know if this is working?

1 Like
#11

Ok cool, thanks. I will try again and let you know if I run into any other issues.

#12

@alexander.forstbach I will go ahead and mark this bug as solved.

If you find any issues from the above, post here and I’ll re-open it.

thanks!