Leiste mit Community-Erfolgen erweitern.

Mark Solution

Diese Konversation wurde aufgrund von Inaktivität geschlossen. Bitte erstellen Sie einen neuen Post.

GELÖST

Privacy Service API request from Firefly Sample App

Avatar

Level 2

I've created a project with the intention of using the Privacy Service APIs.

 

So i've made a few small tweaks:
1) Changed the endpoint to "https://platform.adobe.io/data/core/privacy/jobs?regulation=gdpr&size=100"
2) Changed requiredHeaders to include ['Authorization', 'x-api-key', 'x-gw-ims-org-id']
I've tried the request in Postman and it works fine, so I know there isn't an issue with the headers, but when I run it in localhost I get a 500 error:

 Screenshot 2020-06-11 at 12.21.28.png

 

Am I missing something obvious?
Edit: I didn't mention that I'm just using the sample app that gets generated, and then in index.js I've adjusted the requiredHeaders & apiEndpoint values:

 Screenshot 2020-06-12 at 08.37.42.png

 

 

 

Themen

Anhand von Themen werden Community-Inhalte kategorisiert und Sie können so relevanten Inhalt besser finden.

1 Akzeptierte Lösung

Avatar

Korrekte Antwort von
Employee

I am double-checking with some people to make sure there are no handy helper libs but essentially you will need to forward the headers from the action invoke to your secondary service call.

const res = await fetch(apiEndpoint,{
  headers:{
    "authorization": params.__ow_headers["authorization"],
    "x-api-key": params.__ow_headers["x-api-key"],
    "w-gw-ims-org-id": params.__ow_headers["w-gw-ims-org-id"],
    "x-api-key": params.__ow_headers["x-api-key"]
  }
})

 

Lösung in ursprünglichem Beitrag anzeigen

10 Antworten

Avatar

Employee

Can you post a sample of the code in question?  It is hard to tell the problem from that error message.    

Avatar

Level 2
I've added some additional info in the question; let me know if more is needed

Avatar

Employee

I don't see an error in the code you posted.

In fact, I took the section of code you shared and ran it local and it worked fine. 

500 could be coming from the privacy service.  When you do the fetch on the privacy endpoint are you including all the needed headers, params, and auth needed to make that call?

 

const requiredParams = []
    const requiredHeaders = ['Authorization','x-api-key','w-gw-ims-org-id']
    const errorMessage = checkMissingRequestInputs(params, requiredParams, requiredHeaders)
    if (errorMessage) {
      // return and log client errors
      return errorResponse(400, errorMessage, logger)
    }

 

Avatar

Level 2

These are the debug statements I'm seeing:

Screenshot 2020-06-16 at 00.26.07.png

I'm using Postman to make a request to the same endpoint with the same 4 headers (authorization, content-type, x-gw-ims-org-id and x-api-key) and header values, not seeing any issues.  

 

Avatar

Employee
That would indicate not allowed. Would you mind posting the section of code where you make the fetch call to the privacy server? plz

Avatar

Level 2

So from the framework that was generated, the only things I've changed are row33 and row45

Screenshot 2020-06-16 at 14.11.25.png

I'm using the 'generic' action name:

Screenshot 2020-06-16 at 14.01.08.png

Avatar

Korrekte Antwort von
Employee

I am double-checking with some people to make sure there are no handy helper libs but essentially you will need to forward the headers from the action invoke to your secondary service call.

const res = await fetch(apiEndpoint,{
  headers:{
    "authorization": params.__ow_headers["authorization"],
    "x-api-key": params.__ow_headers["x-api-key"],
    "w-gw-ims-org-id": params.__ow_headers["w-gw-ims-org-id"],
    "x-api-key": params.__ow_headers["x-api-key"]
  }
})

 

Avatar

Level 2
Awesome, thank you, that's worked perfectly!

Avatar

Employee
I will still look around and see if we have helper libs. If not maybe we should make an AdobeFetch that will auto wrap up and pass the auth for you.

Avatar

Employee
glad your fixed up