Closed MarioZagreb closed 5 months ago
Hi. Unfortunately, I am unable to reproduce the issue. Do you think you could open up the network tab in Dev Tools (F12) to show us the response coming back from the request? I would grab that response and paste it into a JSON validator. It would help rule out if the issue is happening within the library, or coming from SharePoint
{ "d": { "ClientPeoplePickerSearchUser": "[{\"Key\":\"i:0#.f|membership|mario.mySurname@aaa.net\",\"DisplayText\":\"mySurname Mario\",\"IsResolved\":true,\"Description\":\"mario.mySurname@aaa.net\",\"EntityType\":\"User\",\"EntityData\":{\"IsAltSecIdPresent\":\"False\",\"UserKey\":\"i:0h.f|membership|100@live.com\",\"Title\":\"ENGINEER\",\"Email\":\"mario.mySurname@aaa.hr\",\"MobilePhone\":\"+0000000000009\",\"ObjectId\":\"988f6d04-55b6-4a9c-93b7-70cc64f7ae81\",\"Department\":\"aaa ICT\"},\"MultipleMatches\":[],\"ProviderName\":\"Tenant\",\"ProviderDisplayName\":\"Tenant\"},{\"Key\":\"i:0#.f|membership|srdan.mySurnameic@aaa.net\",\"DisplayText\":\"mySurnameIC Srdan\",\"IsResolved\":true,\"Description\":\"mario.mySurnameic@aaa.net\",\"EntityType\":\"User\",\"EntityData\":{\"IsAltSecIdPresent\":\"False\",\"UserKey\":\"i:0h.f|membership|10@live.com\",\"Title\":\"ENGINEER\",\"Email\":\"mario.mySurnameic@aaa.hr\",\"MobilePhone\":\"+385 00000000002\",\"ObjectId\":\"bf69ee28-bb0b-492a-a756-415d965e8822\",\"Department\":\"aaa ICT\"},\"MultipleMatches\":[],\"ProviderName\":\"Tenant\",\"ProviderDisplayName\":\"Tenant\"}]" } }
Hi. This does appear to be invalid JSON. It's not escaped, so it's failing at "[{"
To confirm, this is the response found in the Web Browser in Dev Tools from the SharePoint API?
Hi, yes it is a response from the SP API in web browser dev tools. Can you share valid JSON that I am supposed to get?
Hi, so looking into this more.... do you think you could share how you're initiating your SPFI object? Are you using any behaviors (Parsers or Headers)?
Hi, here it is:
pnp.setup({ sp: { baseUrl: "https://aaa", headers: { "Accept": "application/json; odata=verbose" } } });
You are right, I am using headers and I remember adding the line with headers recently, but I can't remember why :)
If you remove those custom headers, does it work?
Yes, it does work without headers
I there a way for initiating SPFI object without using baseUrl? pnp.setup({ sp: { baseUrl: "https://aaa" } });
Can it be done automatically?
pnp.setup is not found in v3 - what version are you really using?
This is from my package.json: "sp-pnp-js": "^3.0.10"
So you're not using a current version of the library. The one you're referencing has been deprecated, as you can see, about 6 years ago:
please see the documentation here for updating to the latest library: PnPjs Getting Started - Specifically the install section. There is also some example projects there that you can reference.
Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
Major Version
3.x
Minor Version Number
3.0.10
Target environment
SharePoint Framework
Additional environment details
This is simple code that I use for user search in my SPfx web part:
var inputTxt = $("#txtNewEmployee").val(); if (inputTxt == undefined) inputTxt = ""; console.log("inputTxt: " + inputTxt);
Expected or Desired Behavior
I use this code to find users and set them to a custom form field.
Observed Behavior
Everything was working fine until recently. Now, I just get this error and I don't know why:
SyntaxError: "[object Object]" is not valid JSON at JSON.parse ()
Steps to Reproduce
This line is written to console: console.log("inputTxt: " + inputTxt);
but this line is not: console.log(items);